forked from TrueCloudLab/rclone
lsjson: add IsBucket field for bucket based remote listing of the root
This commit is contained in:
parent
aa81957586
commit
1aa65d60e1
3 changed files with 14 additions and 3 deletions
|
@ -42,13 +42,16 @@ The output is an array of Items, where each Item looks like this
|
||||||
},
|
},
|
||||||
"ID": "y2djkhiujf83u33",
|
"ID": "y2djkhiujf83u33",
|
||||||
"OrigID": "UYOJVTUW00Q1RzTDA",
|
"OrigID": "UYOJVTUW00Q1RzTDA",
|
||||||
|
"IsBucket" : false,
|
||||||
"IsDir" : false,
|
"IsDir" : false,
|
||||||
"MimeType" : "application/octet-stream",
|
"MimeType" : "application/octet-stream",
|
||||||
"ModTime" : "2017-05-31T16:15:57.034468261+01:00",
|
"ModTime" : "2017-05-31T16:15:57.034468261+01:00",
|
||||||
"Name" : "file.txt",
|
"Name" : "file.txt",
|
||||||
"Encrypted" : "v0qpsdq8anpci8n929v3uu9338",
|
"Encrypted" : "v0qpsdq8anpci8n929v3uu9338",
|
||||||
|
"EncryptedPath" : "kja9098349023498/v0qpsdq8anpci8n929v3uu9338",
|
||||||
"Path" : "full/path/goes/here/file.txt",
|
"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.
|
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".
|
will be "subfolder/file.txt", not "remote:path/subfolder/file.txt".
|
||||||
When used without --recursive the Path will always be the same as Name.
|
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
|
The time is in RFC3339 format with up to nanosecond precision. The
|
||||||
number of decimal digits in the seconds will depend on the precision
|
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
|
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"`
|
ID string `json:",omitempty"`
|
||||||
OrigID string `json:",omitempty"`
|
OrigID string `json:",omitempty"`
|
||||||
Tier string `json:",omitempty"`
|
Tier string `json:",omitempty"`
|
||||||
|
IsBucket bool `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timestamp a time in the provided format
|
// 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")
|
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())
|
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) {
|
err := walk.ListR(fsrc, remote, false, ConfigMaxDepth(opt.Recurse), walk.ListAll, func(entries fs.DirEntries) (err error) {
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
switch entry.(type) {
|
switch entry.(type) {
|
||||||
|
@ -152,6 +155,7 @@ func ListJSON(fsrc fs.Fs, remote string, opt *ListJSONOpt, callback func(*ListJS
|
||||||
switch x := entry.(type) {
|
switch x := entry.(type) {
|
||||||
case fs.Directory:
|
case fs.Directory:
|
||||||
item.IsDir = true
|
item.IsDir = true
|
||||||
|
item.IsBucket = isBucket
|
||||||
case fs.Object:
|
case fs.Object:
|
||||||
item.IsDir = false
|
item.IsDir = false
|
||||||
if opt.ShowHash {
|
if opt.ShowHash {
|
||||||
|
|
|
@ -30,7 +30,7 @@ The result is
|
||||||
- list
|
- list
|
||||||
- This is an array of objects as described in the lsjson command
|
- 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…
Add table
Reference in a new issue