"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
lsf: implement 'i' format for showing object ID - fixes #1476
Nick Craig-Wood909c3a92d671
diff --git a/cmd/lsf/lsf.go b/cmd/lsf/lsf.goindex 633732168..d05b277be 100644--- a/cmd/lsf/lsf.go+++ b/cmd/lsf/lsf.go@@ -63,6 +63,7 @@ output:s - sizet - modification timeh - hash+ i - ID of object if knownSo if you wanted the path, size and modification time, you would use--format "pst", or maybe --format "tsp" to put the path last.@@ -138,6 +139,8 @@ func Lsf(fsrc fs.Fs, out io.Writer) error {list.AddSize()case 'h':list.AddHash(hashType)+ case 'i':+ list.AddID()default:return errors.Errorf("Unknown format character %q", char)}diff --git a/fs/operations/operations.go b/fs/operations/operations.goindex 88e69572c..c0998b696 100644--- a/fs/operations/operations.go+++ b/fs/operations/operations.go@@ -1420,6 +1420,16 @@ func (l *ListFormat) AddHash(ht hash.Type) {})}+// AddID adds file's ID to the output if known+func (l *ListFormat) AddID() {+ l.AppendOutput(func() string {+ if do, ok := l.entry.(fs.IDer); ok {+ return do.ID()+ }+ return ""+ })+}+// AppendOutput adds string generated by specific function to printed outputfunc (l *ListFormat) AppendOutput(functionToAppend func() string) {if len(l.output) > 0 {diff --git a/fs/operations/operations_test.go b/fs/operations/operations_test.goindex aa294663d..a0cedbc43 100644--- a/fs/operations/operations_test.go+++ b/fs/operations/operations_test.go@@ -712,6 +712,10 @@ func TestListFormat(t *testing.T) {list.AddModTime()assert.Equal(t, items[0].ModTime().Local().Format("2006-01-02 15:04:05"), operations.ListFormatted(&items[0], &list))+ list.SetOutput(nil)+ list.AddID()+ _ = operations.ListFormatted(&items[0], &list) // Can't really check anything - at least it didn't panic!+list.SetOutput(nil)list.AddSize()assert.Equal(t, "1", operations.ListFormatted(&items[0], &list))