mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
b2: Fix link sharing #3314
This commit is contained in:
committed by
Nick Craig-Wood
parent
a35aa1360e
commit
ccc416e62b
@@ -629,6 +629,10 @@ func (f *Fs) list(ctx context.Context, dir string, recurse bool, prefix string,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Check that there are matching files
|
||||
if len(response.Files) == 0 {
|
||||
return fs.ErrorDirNotFound
|
||||
}
|
||||
for i := range response.Files {
|
||||
file := &response.Files[i]
|
||||
// Finish if file name no longer has prefix
|
||||
@@ -1227,6 +1231,15 @@ func (f *Fs) PublicLink(ctx context.Context, remote string) (link string, err er
|
||||
} else {
|
||||
RootURL = f.opt.DownloadURL
|
||||
}
|
||||
_, err = f.NewObject(ctx, remote)
|
||||
if err == fs.ErrorObjectNotFound || err == fs.ErrorNotAFile {
|
||||
err = f.list(ctx, remote, false, "", 1, f.opt.Versions, func(remote string, object *api.File, isDirectory bool) error {
|
||||
return errEndList
|
||||
})
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
absPath := "/" + path.Join(f.root, remote)
|
||||
link = RootURL + "/file/" + urlEncode(f.bucket) + absPath
|
||||
bucketType, err := f.getbucketType()
|
||||
|
||||
Reference in New Issue
Block a user