]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm-remote/sync/files.go
sync: include size in binary "diff"
[safcm/safcm.git] / cmd / safcm-remote / sync / files.go
index 119a3534239f68e2e5d10aee08ec2559590ada87..3e88be2b6f2ff78ead5af113846fc6cc302c1f0f 100644 (file)
@@ -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("<binary content>\n")
+               oldData = []byte(fmt.Sprintf("<binary content, %d bytes>\n",
+                       len(oldData)))
        }
        if newBin {
-               newData = []byte("<binary content>\n")
+               newData = []byte(fmt.Sprintf("<binary content, %d bytes>\n",
+                       len(newData)))
        }
 
        // TODO: difflib shows empty context lines at the end of the file