Ignore symlink errors
This commit is contained in:
parent
7549eb13a0
commit
68749616ad
|
@ -3,6 +3,7 @@ package filesystem
|
||||||
import (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
"emperror.dev/errors"
|
"emperror.dev/errors"
|
||||||
|
"github.com/apex/log"
|
||||||
"github.com/juju/ratelimit"
|
"github.com/juju/ratelimit"
|
||||||
"github.com/karrick/godirwalk"
|
"github.com/karrick/godirwalk"
|
||||||
"github.com/klauspost/pgzip"
|
"github.com/klauspost/pgzip"
|
||||||
|
@ -149,21 +150,23 @@ func (a *Archive) addToArchive(p string, rp string, w *tar.Writer) error {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.WrapIff(err, "failed to Lstat '"+rp+"'")
|
return errors.WrapIff(err, "failed executing os.Lstat on '%s'", rp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve the symlink target if the file is a symlink.
|
// Resolve the symlink target if the file is a symlink.
|
||||||
var target string
|
var target string
|
||||||
if s.Mode()&os.ModeSymlink != 0 {
|
if s.Mode()&os.ModeSymlink != 0 {
|
||||||
// Read the target of the symlink.
|
// Read the target of the symlink. If there are any errors we will dump them out to
|
||||||
|
// the logs, but we're not going to stop the backup. There are far too many cases of
|
||||||
|
// symlinks causing all sorts of unnecessary pain in this process. Sucks to suck if
|
||||||
|
// it doesn't work.
|
||||||
target, err = os.Readlink(s.Name())
|
target, err = os.Readlink(s.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Skip symlinks if the target does not exist.
|
// Ignore the not exist errors specifically, since theres nothing important about that.
|
||||||
if os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
return nil
|
log.WithField("path", rp).WithField("readlink_err", err.Error()).Warn("failed reading symlink for target path; skipping...")
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
return errors.WrapIff(err, "failed to read symlink target for '%s'", rp)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user