diff --git a/cmd/lsf/lsf.go b/cmd/lsf/lsf.go index 21fc38690..1b9ef17ea 100644 --- a/cmd/lsf/lsf.go +++ b/cmd/lsf/lsf.go @@ -70,6 +70,7 @@ output: o - Original ID of underlying object m - MimeType of object if known 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 --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': list.AddOrigID() opt.ShowOrigIDs = true + case 'T': + list.AddTier() default: return errors.Errorf("Unknown format character %q", char) } diff --git a/fs/operations/lsjson.go b/fs/operations/lsjson.go index a9d8862e5..2ca60bc6b 100644 --- a/fs/operations/lsjson.go +++ b/fs/operations/lsjson.go @@ -23,6 +23,7 @@ type ListJSONItem struct { Hashes map[string]string `json:",omitempty"` ID string `json:",omitempty"` OrigID string `json:",omitempty"` + Tier string `json:",omitempty"` } // 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") } } + canGetTier := fsrc.Features().GetTier format := formatForPrecision(fsrc.Precision()) err := walk.ListR(fsrc, remote, false, ConfigMaxDepth(opt.Recurse), walk.ListAll, func(entries fs.DirEntries) (err error) { 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: fs.Errorf(nil, "Unknown type %T in listing in ListJSON", entry) } diff --git a/fs/operations/operations.go b/fs/operations/operations.go index 0a265f140..a04b356c4 100644 --- a/fs/operations/operations.go +++ b/fs/operations/operations.go @@ -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 func (l *ListFormat) AddMimeType() { l.AppendOutput(func(entry *ListJSONItem) string {