X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm-remote%2Fsync%2Ffiles.go;h=3e88be2b6f2ff78ead5af113846fc6cc302c1f0f;hb=e0d1ceb383e5672de1a414f192eb2849a1887934;hp=f3886065803781d8b0c0613766fbe981e8d4f61e;hpb=583a2695a3ddc9c98e0a03d9f1bad8df30afe887;p=safcm%2Fsafcm.git diff --git a/cmd/safcm-remote/sync/files.go b/cmd/safcm-remote/sync/files.go index f388606..3e88be2 100644 --- a/cmd/safcm-remote/sync/files.go +++ b/cmd/safcm-remote/sync/files.go @@ -152,8 +152,8 @@ reopen: if change.Old.Mode.Type() == fs.ModeSymlink { // Some BSD systems permit changing permissions of // symlinks but ignore them on traversal. To keep it - // simple we don't support that and always use 0777 for - // symlink permissions (the value on GNU/Linux). + // simple we don't support that and always use 0777 + // for symlink permissions (the value on GNU/Linux). // // TODO: Add proper support for symlinks on BSD change.Old.Mode |= 0777 @@ -267,7 +267,7 @@ reopen: } } - // Directory: create new directory (also type change to directory) + // Directory: create new directory, also type change to directory if file.Mode.IsDir() && (change.Created || changeType) { debugf("creating directory") err := os.Mkdir(file.Path, 0700) @@ -373,7 +373,7 @@ reopen: os.Remove(tmpPath) return err } - // Permissions are irrelevant for symlinks + // Permissions are irrelevant for symlinks (on most systems) default: panic(fmt.Sprintf("invalid file type %s", file.Mode)) @@ -452,13 +452,16 @@ func diffData(oldData []byte, newData []byte) (string, error) { oldBin := !strings.HasPrefix(http.DetectContentType(oldData), "text/") newBin := !strings.HasPrefix(http.DetectContentType(newData), "text/") if oldBin && newBin { - return "Binary files differ, cannot show diff", nil + return fmt.Sprintf("Binary files differ (%d -> %d bytes), "+ + "cannot show diff", len(oldData), len(newData)), nil } if oldBin { - oldData = []byte("\n") + oldData = []byte(fmt.Sprintf("\n", + len(oldData))) } if newBin { - newData = []byte("\n") + newData = []byte(fmt.Sprintf("\n", + len(newData))) } // TODO: difflib shows empty context lines at the end of the file