Skip to content

Commit

Permalink
fuse: Use correct file size in case it's zero
Browse files Browse the repository at this point in the history
  • Loading branch information
fd0 committed May 8, 2016
1 parent 25e5f6a commit af39e93
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/restic/fuse/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var blobPool = sync.Pool{

func newFile(repo BlobLoader, node *restic.Node, ownerIsRoot bool) (*file, error) {
debug.Log("newFile", "create new file for %v with %d blobs", node.Name, len(node.Content))
var bytes uint64
sizes := make([]uint, len(node.Content))
for i, id := range node.Content {
size, err := repo.LookupBlobSize(id)
Expand All @@ -57,6 +58,12 @@ func newFile(repo BlobLoader, node *restic.Node, ownerIsRoot bool) (*file, error
}

sizes[i] = size
bytes += uint64(size)
}

if bytes != node.Size {
debug.Log("newFile", "sizes do not match: node.Size %v != size %v, using real size", node.Size, bytes)
node.Size = bytes
}

return &file{
Expand Down

0 comments on commit af39e93

Please sign in to comment.