func TestMd5sum(t *testing.T) { r := NewRun(t) defer r.Finalise() file1 := r.WriteBoth("potato2", "------------------------------------------------------------", t1) file2 := r.WriteBoth("empty space", "", t2) fstest.CheckItems(t, r.fremote, file1, file2) var buf bytes.Buffer err := fs.Md5sum(r.fremote, &buf) if err != nil { t.Fatalf("List failed: %v", err) } res := buf.String() if !strings.Contains(res, "d41d8cd98f00b204e9800998ecf8427e empty space\n") && !strings.Contains(res, " UNSUPPORTED empty space\n") && !strings.Contains(res, " empty space\n") { t.Errorf("empty space missing: %q", res) } if !strings.Contains(res, "6548b156ea68a4e003e786df99eee76 potato2\n") && !strings.Contains(res, " UNSUPPORTED potato2\n") && !strings.Contains(res, " potato2\n") { t.Errorf("potato2 missing: %q", res) } }
func TestMd5sum(t *testing.T) { var buf bytes.Buffer err := fs.Md5sum(fremote, &buf) if err != nil { t.Fatalf("List failed: %v", err) } res := buf.String() if !strings.Contains(res, "d41d8cd98f00b204e9800998ecf8427e empty space\n") && !strings.Contains(res, " empty space\n") { t.Errorf("empty space missing: %q", res) } if !strings.Contains(res, "6548b156ea68a4e003e786df99eee76 potato2\n") && !strings.Contains(res, " potato2\n") { t.Errorf("potato2 missing: %q", res) } }
List all the objects in the the path with modification time, size and path.`, Run: func(fdst, fsrc fs.Fs) error { return fs.ListLong(fdst, os.Stdout) }, MinArgs: 1, MaxArgs: 1, }, { Name: "md5sum", ArgsHelp: "[remote:path]", Help: ` Produces an md5sum file for all the objects in the path. This is in the same format as the standard md5sum tool produces.`, Run: func(fdst, fsrc fs.Fs) error { return fs.Md5sum(fdst, os.Stdout) }, MinArgs: 1, MaxArgs: 1, }, { Name: "mkdir", ArgsHelp: "remote:path", Help: ` Make the path if it doesn't already exist`, Run: func(fdst, fsrc fs.Fs) error { return fs.Mkdir(fdst) }, MinArgs: 1, MaxArgs: 1, Retry: true,
package md5sum import ( "os" "github.com/ncw/rclone/cmd" "github.com/ncw/rclone/fs" "github.com/spf13/cobra" ) func init() { cmd.Root.AddCommand(md5sumCmd) } var md5sumCmd = &cobra.Command{ Use: "md5sum remote:path", Short: `Produces an md5sum file for all the objects in the path.`, Long: ` Produces an md5sum file for all the objects in the path. This is in the same format as the standard md5sum tool produces. `, Run: func(command *cobra.Command, args []string) { cmd.CheckArgs(1, 1, command, args) fsrc := cmd.NewFsSrc(args) cmd.Run(false, command, func() error { return fs.Md5sum(fsrc, os.Stdout) }) }, }
err := fs.ListLong(fdst, os.Stdout) if err != nil { log.Fatalf("Failed to list long: %v", err) } }, MinArgs: 1, MaxArgs: 1, }, { Name: "md5sum", ArgsHelp: "[remote:path]", Help: ` Produces an md5sum file for all the objects in the path. This is in the same format as the standard md5sum tool produces.`, Run: func(fdst, fsrc fs.Fs) { err := fs.Md5sum(fdst, os.Stdout) if err != nil { log.Fatalf("Failed to list: %v", err) } }, MinArgs: 1, MaxArgs: 1, }, { Name: "mkdir", ArgsHelp: "remote:path", Help: ` Make the path if it doesn't already exist`, Run: func(fdst, fsrc fs.Fs) { err := fs.Mkdir(fdst) if err != nil {