mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 14:22:04 +08:00
lsjson: add IsBucket field for bucket based remote listing of the root
This commit is contained in:
parent
aa81957586
commit
1aa65d60e1
|
@ -42,13 +42,16 @@ The output is an array of Items, where each Item looks like this
|
|||
},
|
||||
"ID": "y2djkhiujf83u33",
|
||||
"OrigID": "UYOJVTUW00Q1RzTDA",
|
||||
"IsBucket" : false,
|
||||
"IsDir" : false,
|
||||
"MimeType" : "application/octet-stream",
|
||||
"ModTime" : "2017-05-31T16:15:57.034468261+01:00",
|
||||
"Name" : "file.txt",
|
||||
"Encrypted" : "v0qpsdq8anpci8n929v3uu9338",
|
||||
"EncryptedPath" : "kja9098349023498/v0qpsdq8anpci8n929v3uu9338",
|
||||
"Path" : "full/path/goes/here/file.txt",
|
||||
"Size" : 6
|
||||
"Size" : 6,
|
||||
"Tier" : "hot",
|
||||
}
|
||||
|
||||
If --hash is not specified the Hashes property won't be emitted.
|
||||
|
@ -66,6 +69,10 @@ If "remote:path" contains the file "subfolder/file.txt", the Path for "file.txt"
|
|||
will be "subfolder/file.txt", not "remote:path/subfolder/file.txt".
|
||||
When used without --recursive the Path will always be the same as Name.
|
||||
|
||||
If the directory is a bucket in a bucket based backend, then
|
||||
"IsBucket" will be set to true. This key won't be present unless it is
|
||||
"true".
|
||||
|
||||
The time is in RFC3339 format with up to nanosecond precision. The
|
||||
number of decimal digits in the seconds will depend on the precision
|
||||
that the remote can hold the times, so if times are accurate to the
|
||||
|
|
|
@ -24,6 +24,7 @@ type ListJSONItem struct {
|
|||
ID string `json:",omitempty"`
|
||||
OrigID string `json:",omitempty"`
|
||||
Tier string `json:",omitempty"`
|
||||
IsBucket bool `json:",omitempty"`
|
||||
}
|
||||
|
||||
// Timestamp a time in the provided format
|
||||
|
@ -92,8 +93,10 @@ func ListJSON(fsrc fs.Fs, remote string, opt *ListJSONOpt, callback func(*ListJS
|
|||
return errors.Wrap(err, "ListJSON failed to make new crypt remote")
|
||||
}
|
||||
}
|
||||
canGetTier := fsrc.Features().GetTier
|
||||
features := fsrc.Features()
|
||||
canGetTier := features.GetTier
|
||||
format := formatForPrecision(fsrc.Precision())
|
||||
isBucket := features.BucketBased && remote == "" && fsrc.Root() == "" // if bucket based remote listing the root mark directories as buckets
|
||||
err := walk.ListR(fsrc, remote, false, ConfigMaxDepth(opt.Recurse), walk.ListAll, func(entries fs.DirEntries) (err error) {
|
||||
for _, entry := range entries {
|
||||
switch entry.(type) {
|
||||
|
@ -152,6 +155,7 @@ func ListJSON(fsrc fs.Fs, remote string, opt *ListJSONOpt, callback func(*ListJS
|
|||
switch x := entry.(type) {
|
||||
case fs.Directory:
|
||||
item.IsDir = true
|
||||
item.IsBucket = isBucket
|
||||
case fs.Object:
|
||||
item.IsDir = false
|
||||
if opt.ShowHash {
|
||||
|
|
|
@ -30,7 +30,7 @@ The result is
|
|||
- list
|
||||
- This is an array of objects as described in the lsjson command
|
||||
|
||||
See the lsjson command for more information on the above and examples.
|
||||
See the [lsjson command](/commands/rclone_lsjson/) for more information on the above and examples.
|
||||
`,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user