forked from TrueCloudLab/rclone
lsjson, lsf: support showing the Tier of the object
This commit is contained in:
parent
eeab7a0a43
commit
a57756a05c
3 changed files with 17 additions and 0 deletions
|
@ -70,6 +70,7 @@ output:
|
||||||
o - Original ID of underlying object
|
o - Original ID of underlying object
|
||||||
m - MimeType of object if known
|
m - MimeType of object if known
|
||||||
e - encrypted name
|
e - encrypted name
|
||||||
|
T - tier of storage if known, eg "Hot" or "Cool"
|
||||||
|
|
||||||
So if you wanted the path, size and modification time, you would use
|
So if you wanted the path, size and modification time, you would use
|
||||||
--format "pst", or maybe --format "tsp" to put the path last.
|
--format "pst", or maybe --format "tsp" to put the path last.
|
||||||
|
@ -191,6 +192,8 @@ func Lsf(fsrc fs.Fs, out io.Writer) error {
|
||||||
case 'o':
|
case 'o':
|
||||||
list.AddOrigID()
|
list.AddOrigID()
|
||||||
opt.ShowOrigIDs = true
|
opt.ShowOrigIDs = true
|
||||||
|
case 'T':
|
||||||
|
list.AddTier()
|
||||||
default:
|
default:
|
||||||
return errors.Errorf("Unknown format character %q", char)
|
return errors.Errorf("Unknown format character %q", char)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ type ListJSONItem struct {
|
||||||
Hashes map[string]string `json:",omitempty"`
|
Hashes map[string]string `json:",omitempty"`
|
||||||
ID string `json:",omitempty"`
|
ID string `json:",omitempty"`
|
||||||
OrigID string `json:",omitempty"`
|
OrigID string `json:",omitempty"`
|
||||||
|
Tier string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timestamp a time in the provided format
|
// Timestamp a time in the provided format
|
||||||
|
@ -91,6 +92,7 @@ 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
|
||||||
format := formatForPrecision(fsrc.Precision())
|
format := formatForPrecision(fsrc.Precision())
|
||||||
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 {
|
||||||
|
@ -163,6 +165,11 @@ func ListJSON(fsrc fs.Fs, remote string, opt *ListJSONOpt, callback func(*ListJS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if canGetTier {
|
||||||
|
if do, ok := x.(fs.GetTierer); ok {
|
||||||
|
item.Tier = do.GetTier()
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
fs.Errorf(nil, "Unknown type %T in listing in ListJSON", entry)
|
fs.Errorf(nil, "Unknown type %T in listing in ListJSON", entry)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1596,6 +1596,13 @@ func (l *ListFormat) AddOrigID() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddTier adds file's Tier to the output if known
|
||||||
|
func (l *ListFormat) AddTier() {
|
||||||
|
l.AppendOutput(func(entry *ListJSONItem) string {
|
||||||
|
return entry.Tier
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// AddMimeType adds file's MimeType to the output if known
|
// AddMimeType adds file's MimeType to the output if known
|
||||||
func (l *ListFormat) AddMimeType() {
|
func (l *ListFormat) AddMimeType() {
|
||||||
l.AppendOutput(func(entry *ListJSONItem) string {
|
l.AppendOutput(func(entry *ListJSONItem) string {
|
||||||
|
|
Loading…
Reference in a new issue