Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

lsjson: add ID field to output to show Object ID - fixes #1901

Nick Craig-Woodf16211613277
diff --git a/cmd/lsjson/lsjson.go b/cmd/lsjson/lsjson.go
index 9ca517ec1..dac4c56aa 100644
--- a/cmd/lsjson/lsjson.go
+++ b/cmd/lsjson/lsjson.go
@@ -42,6 +42,7 @@ type lsJSON struct {
ModTime Timestamp //`json:",omitempty"`
IsDir bool
Hashes map[string]string `json:",omitempty"`
+ ID string `json:",omitempty"`
}
// Timestamp a time in RFC3339 format with Nanosecond precision secongs
@@ -69,6 +70,7 @@ The output is an array of Items, where each Item looks like this
"MD5" : "b1946ac92492d2347c6235b4d2611184",
"DropboxHash" : "ecb65bb98f9d905b70458986c39fcbad7715e5f2fcc3b1f07767d7c83e2438cc"
},
+ "ID": "y2djkhiujf83u33",
"IsDir" : false,
"ModTime" : "2017-05-31T16:15:57.034468261+01:00",
"Name" : "file.txt",
@@ -138,6 +140,9 @@ can be processed line by line as each item is written one to a line.
fs.Errorf(nil, "Unknown type %T in listing", entry)
}
}
+ if do, ok := entry.(fs.IDer); ok {
+ item.ID = do.ID()
+ }
switch x := entry.(type) {
case fs.Directory:
item.IsDir = true