mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 19:08:55 +00:00
Merge pull request #3780 from jkmw/fix/2578
Remove existing path before restoring a symlink
This commit is contained in:
commit
041a51512a
7
changelog/unreleased/pull-3780
Normal file
7
changelog/unreleased/pull-3780
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Bugfix: Make sure that symlinks can be created during recovery
|
||||||
|
|
||||||
|
When restoring a symlink, restic reported an error if the target path already existed.
|
||||||
|
With this change, the potentially existing target path is first removed before the symlink is recreated.
|
||||||
|
|
||||||
|
https://github.com/restic/restic/issues/2578
|
||||||
|
https://github.com/restic/restic/pull/3780
|
@ -299,8 +299,12 @@ func (node Node) createSymlinkAt(path string) error {
|
|||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
err := fs.Symlink(node.LinkTarget, path)
|
|
||||||
if err != nil {
|
if err := os.Remove(path); err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||||
|
return errors.Wrap(err, "Symlink")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := fs.Symlink(node.LinkTarget, path); err != nil {
|
||||||
return errors.Wrap(err, "Symlink")
|
return errors.Wrap(err, "Symlink")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user