Merge pull request #1390 from armhold/lint

small cleanup
This commit is contained in:
Alexander Neumann
2017-10-28 09:54:35 +02:00
9 changed files with 31 additions and 16 deletions
+1 -1
View File
@@ -109,7 +109,7 @@ func newLock(ctx context.Context, repo Repository, excl bool) (*Lock, error) {
time.Sleep(waitBeforeLockCheck)
if err = lock.checkForOtherLocks(ctx); err != nil {
lock.Unlock()
_ = lock.Unlock()
return nil, err
}
+19 -5
View File
@@ -253,8 +253,26 @@ func (node Node) createFileAt(ctx context.Context, path string, repo Repository,
if err != nil {
return errors.Wrap(err, "OpenFile")
}
defer f.Close()
err = node.writeNodeContent(ctx, repo, f)
closeErr := f.Close()
if err != nil {
return err
}
if closeErr != nil {
return errors.Wrap(closeErr, "Close")
}
if node.Links > 1 {
idx.Add(node.Inode, node.DeviceID, path)
}
return nil
}
func (node Node) writeNodeContent(ctx context.Context, repo Repository, f *os.File) error {
var buf []byte
for _, id := range node.Content {
size, err := repo.LookupBlobSize(id, DataBlob)
@@ -279,10 +297,6 @@ func (node Node) createFileAt(ctx context.Context, path string, repo Repository,
}
}
if node.Links > 1 {
idx.Add(node.Inode, node.DeviceID, path)
}
return nil
}
+3 -2
View File
@@ -51,7 +51,7 @@ func (res *Restorer) restoreTo(ctx context.Context, dst string, dir string, tree
debug.Log("SelectFilter returned %v %v", selectedForRestore, childMayBeSelected)
if selectedForRestore {
err := res.restoreNodeTo(ctx, node, dir, dst, idx)
err = res.restoreNodeTo(ctx, node, dir, dst, idx)
if err != nil {
return err
}
@@ -74,7 +74,8 @@ func (res *Restorer) restoreTo(ctx context.Context, dst string, dir string, tree
if selectedForRestore {
// Restore directory timestamp at the end. If we would do it earlier, restoring files within
// the directory would overwrite the timestamp of the directory they are in.
if err := node.RestoreTimestamps(filepath.Join(dst, dir, node.Name)); err != nil {
err = node.RestoreTimestamps(filepath.Join(dst, dir, node.Name))
if err != nil {
return err
}
}