mirror of
https://github.com/restic/restic.git
synced 2026-07-12 18:25:10 +00:00
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user