Treat changed files as a warning, not an error

This commit is contained in:
Alexander Neumann 2016-12-10 17:14:13 +01:00
parent 3fcbb4ac25
commit e6a40af06d
2 changed files with 8 additions and 10 deletions

View File

@ -431,10 +431,9 @@ func runBackup(opts BackupOptions, gopts GlobalOptions, args []string) error {
arch.Excludes = opts.Excludes
arch.SelectFilter = selectFilter
arch.Error = func(dir string, fi os.FileInfo, err error) error {
arch.Warn = func(dir string, fi os.FileInfo, err error) {
// TODO: make ignoring errors configurable
Warnf("%s\rerror for %s: %v\n", ClearLine(), dir, err)
return nil
Warnf("%s\rwarning for %s: %v\n", ClearLine(), dir, err)
}
_, id, err := arch.Snapshot(newArchiveProgress(gopts, stat), target, opts.Tags, parentSnapshotID)

View File

@ -26,7 +26,9 @@ const (
maxConcurrency = 10
)
var archiverAbortOnAllErrors = func(str string, fi os.FileInfo, err error) error { return err }
var archiverPrintWarnings = func(path string, fi os.FileInfo, err error) {
fmt.Fprintf(os.Stderr, "warning for %v: %v", path, err)
}
var archiverAllowAllFiles = func(string, os.FileInfo) bool { return true }
// Archiver is used to backup a set of directories.
@ -39,7 +41,7 @@ type Archiver struct {
blobToken chan struct{}
Error func(dir string, fi os.FileInfo, err error) error
Warn func(dir string, fi os.FileInfo, err error)
SelectFilter pipe.SelectFunc
Excludes []string
}
@ -61,7 +63,7 @@ func New(repo restic.Repository) *Archiver {
arch.blobToken <- struct{}{}
}
arch.Error = archiverAbortOnAllErrors
arch.Warn = archiverPrintWarnings
arch.SelectFilter = archiverAllowAllFiles
return arch
@ -135,10 +137,7 @@ func (arch *Archiver) reloadFileIfChanged(node *restic.Node, file fs.File) (*res
return node, nil
}
err = arch.Error(node.Path, fi, errors.New("file has changed"))
if err != nil {
return nil, err
}
arch.Warn(node.Path, fi, errors.New("file has changed"))
node, err = restic.NodeFromFileInfo(node.Path, fi)
if err != nil {