From 3f7651291b98534ea27d4036fec446f4618896be Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 8 Sep 2024 12:13:06 +0100 Subject: [PATCH] gofile: fix failed downloads on newly uploaded objects The upload routine no longer returns a url to download the object. This fixes the problem by fetching it if necessary when we attempt to Open the object. --- backend/gofile/gofile.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/gofile/gofile.go b/backend/gofile/gofile.go index f6906b4e6..8f7b98b89 100644 --- a/backend/gofile/gofile.go +++ b/backend/gofile/gofile.go @@ -1469,6 +1469,13 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read if o.id == "" { return nil, errors.New("can't download - no id") } + if o.url == "" { + // On upload an Object is returned with no url, so fetch it here if needed + err = o.readMetaData(ctx) + if err != nil { + return nil, fmt.Errorf("read metadata: %w", err) + } + } fs.FixRangeOption(options, o.size) var resp *http.Response opts := rest.Opts{