Skip to content

Commit

Permalink
Don't set size on non-file-like entries
Browse files Browse the repository at this point in the history
Don't set size on console output and metadata files. The plugin system
knows how to get the size just as efficiently, and explicitly setting
the size implies they'll behave like files (which may not be true).

Signed-off-by: Michael Smith <[email protected]>
  • Loading branch information
MikaelSmith committed Jan 3, 2020
1 parent 756b4e7 commit 5f0ad9a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
3 changes: 1 addition & 2 deletions plugin/aws/ec2InstanceConsoleOutput.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ func newEC2InstanceConsoleOutput(ctx context.Context, inst *ec2Instance, latest
SetCrtime(output.mtime).
SetMtime(output.mtime).
SetCtime(output.mtime).
SetAtime(output.mtime).
SetSize(uint64(len(output.content)))
SetAtime(output.mtime)

return cl, nil
}
Expand Down
16 changes: 2 additions & 14 deletions plugin/metadataJSON.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,10 @@ type MetadataJSONFile struct {
// NewMetadataJSONFile creates a new MetadataJSONFile. If caching Metadata on the `other` entry is
// disabled, it will use that to compute the file size upfront.
func NewMetadataJSONFile(ctx context.Context, other Entry) (*MetadataJSONFile, error) {
meta := &MetadataJSONFile{
return &MetadataJSONFile{
EntryBase: NewEntry("metadata.json"),
other: other,
}

if other.getTTLOf(MetadataOp) < 0 {
// Content is presumably easy to get, so use it to determine size.
content, err := meta.Read(ctx)
if err != nil {
return nil, err
}

meta.Attributes().SetSize(uint64(len(content)))
}

return meta, nil
}, nil
}

// Schema defines the schema of a metadata.json file.
Expand Down

0 comments on commit 5f0ad9a

Please sign in to comment.