Skip to content

Commit

Permalink
Merge pull request #53 from egroenen/master
Browse files Browse the repository at this point in the history
Added -skip-error option when syncing to ignore files that can't be read...
  • Loading branch information
t3rm1n4l committed Mar 12, 2015
2 parents d8689e5 + 9f20ef4 commit d7f3f3a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Config struct {
Recursive bool
Force bool
SkipSameSize bool
SkipError bool
Verbose int
}

Expand Down Expand Up @@ -584,7 +585,7 @@ func (mc *MegaClient) Sync(src, dst string) error {
paths = append(paths, getRemotePaths(mc.mega.FS, n, true)...)
}
} else {
paths, err = getLocalPaths(src)
paths, err = getLocalPaths(src, mc.cfg.SkipError)
if err != nil {
return err
}
Expand Down
9 changes: 7 additions & 2 deletions client/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,19 @@ func getRemotePaths(fs *mega.MegaFS, n *mega.Node, recursive bool) []Path {
return paths
}

func getLocalPaths(root string) ([]Path, error) {
func getLocalPaths(root string, skiperror bool) ([]Path, error) {
var paths []Path

walker := func(p string, info os.FileInfo, err error) error {
var x Path
p, _ = filepath.Rel(root, p)

if err != nil {
return err
if skiperror {
return nil
} else {
return err
}
}

if p == "." {
Expand Down
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func main() {
recursive = flag.Bool("recursive", false, "Recursive listing")
force = flag.Bool("force", false, "Force hard delete or overwrite")
skipsize = flag.Bool("skip-same-size", false, "Skip copying of files with same size and path suffix")
skiperror = flag.Bool("skip-error", false, "Skip syncing of files that can't be read")
)

log.SetFlags(0)
Expand Down Expand Up @@ -99,6 +100,10 @@ func main() {
conf.SkipSameSize = true
}

if *skiperror {
conf.SkipError = true
}

go func() {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
Expand Down

0 comments on commit d7f3f3a

Please sign in to comment.