lsjson: added EncryptedPath to output - fixes #3094

This commit is contained in:
calisro 2019-04-15 13:12:09 -04:00 committed by Nick Craig-Wood
parent f5795db6d2
commit 8190a81201

View File

@ -14,6 +14,7 @@ import (
type ListJSONItem struct {
Path string
Name string
EncryptedPath string `json:",omitempty"`
Encrypted string `json:",omitempty"`
Size int64
MimeType string `json:",omitempty"`
@ -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()