fs: Implement UnWrapObject and UnWrapFs

This commit is contained in:
Nick Craig-Wood 2019-08-12 22:03:53 +01:00
parent 7c146e2618
commit 752d43d6fa
3 changed files with 35 additions and 22 deletions

View file

@ -136,20 +136,8 @@ func ListJSON(ctx context.Context, fsrc fs.Fs, remote string, opt *ListJSONOpt,
if do, ok := entry.(fs.IDer); ok {
item.ID = do.ID()
}
if opt.ShowOrigIDs {
cur := entry
for {
u, ok := cur.(fs.ObjectUnWrapper)
if !ok {
break // not a wrapped object, use current id
}
next := u.UnWrap()
if next == nil {
break // no base object found, use current id
}
cur = next
}
if do, ok := cur.(fs.IDer); ok {
if o, ok := entry.(fs.Object); opt.ShowOrigIDs && ok {
if do, ok := fs.UnWrapObject(o).(fs.IDer); ok {
item.OrigID = do.ID()
}
}