From ac8d1db8d3be7e11b5cf829a9ff8a95ed5dbbe77 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 20 Mar 2019 11:59:26 +0000 Subject: [PATCH] crypt: support PublicLink (rclone link) of underlying backend - fixes #3042 --- backend/crypt/crypt.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/backend/crypt/crypt.go b/backend/crypt/crypt.go index 609d41692..6e76cde9f 100644 --- a/backend/crypt/crypt.go +++ b/backend/crypt/crypt.go @@ -635,6 +635,20 @@ func (f *Fs) DirCacheFlush() { } } +// PublicLink generates a public link to the remote path (usually readable by anyone) +func (f *Fs) PublicLink(remote string) (string, error) { + do := f.Fs.Features().PublicLink + if do == nil { + return "", errors.New("PublicLink not supported") + } + o, err := f.NewObject(remote) + if err != nil { + // assume it is a directory + return do(f.cipher.EncryptDirName(remote)) + } + return do(o.(*Object).Object.Remote()) +} + // ChangeNotify calls the passed function with a path // that has had changes. If the implementation // uses polling, it should adhere to the given interval. @@ -838,6 +852,11 @@ var ( _ fs.UnWrapper = (*Fs)(nil) _ fs.ListRer = (*Fs)(nil) _ fs.Abouter = (*Fs)(nil) + _ fs.Wrapper = (*Fs)(nil) + _ fs.MergeDirser = (*Fs)(nil) + _ fs.DirCacheFlusher = (*Fs)(nil) + _ fs.ChangeNotifier = (*Fs)(nil) + _ fs.PublicLinker = (*Fs)(nil) _ fs.ObjectInfo = (*ObjectInfo)(nil) _ fs.Object = (*Object)(nil) _ fs.ObjectUnWrapper = (*Object)(nil)