From 8190a81201118b8da86d00c59cef03b30b5cb472 Mon Sep 17 00:00:00 2001 From: calisro Date: Mon, 15 Apr 2019 13:12:09 -0400 Subject: [PATCH] lsjson: added EncryptedPath to output - fixes #3094 --- fs/operations/lsjson.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/fs/operations/lsjson.go b/fs/operations/lsjson.go index 876a71ef5..a9d8862e5 100644 --- a/fs/operations/lsjson.go +++ b/fs/operations/lsjson.go @@ -12,16 +12,17 @@ import ( // ListJSONItem in the struct which gets marshalled for each line type ListJSONItem struct { - Path string - Name string - Encrypted string `json:",omitempty"` - Size int64 - MimeType string `json:",omitempty"` - ModTime Timestamp //`json:",omitempty"` - IsDir bool - Hashes map[string]string `json:",omitempty"` - ID string `json:",omitempty"` - OrigID string `json:",omitempty"` + Path string + Name string + EncryptedPath string `json:",omitempty"` + Encrypted string `json:",omitempty"` + Size int64 + MimeType string `json:",omitempty"` + ModTime Timestamp //`json:",omitempty"` + IsDir bool + Hashes map[string]string `json:",omitempty"` + ID string `json:",omitempty"` + OrigID string `json:",omitempty"` } // Timestamp a time in the provided format @@ -118,12 +119,13 @@ func ListJSON(fsrc fs.Fs, remote string, opt *ListJSONOpt, callback func(*ListJS if cipher != nil { switch entry.(type) { case fs.Directory: - item.Encrypted = cipher.EncryptDirName(path.Base(entry.Remote())) + item.EncryptedPath = cipher.EncryptDirName(entry.Remote()) case fs.Object: - item.Encrypted = cipher.EncryptFileName(path.Base(entry.Remote())) + item.EncryptedPath = cipher.EncryptFileName(entry.Remote()) default: fs.Errorf(nil, "Unknown type %T in listing", entry) } + item.Encrypted = path.Base(item.EncryptedPath) } if do, ok := entry.(fs.IDer); ok { item.ID = do.ID()