From 306a0319536eec65cbadb554b4560e9263a45100 Mon Sep 17 00:00:00 2001 From: genofire Date: Sun, 2 Oct 2022 00:25:40 +0200 Subject: [PATCH] filestore: keep ID passed to NewUpload, if available (#820) * fix(filestore): keep info.ID * fix --- pkg/filestore/filestore.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/filestore/filestore.go b/pkg/filestore/filestore.go index 1f79279..77ebf05 100644 --- a/pkg/filestore/filestore.go +++ b/pkg/filestore/filestore.go @@ -49,9 +49,10 @@ func (store FileStore) UseIn(composer *handler.StoreComposer) { } func (store FileStore) NewUpload(ctx context.Context, info handler.FileInfo) (handler.Upload, error) { - id := uid.Uid() - binPath := store.binPath(id) - info.ID = id + if info.ID == "" { + info.ID = uid.Uid() + } + binPath := store.binPath(info.ID) info.Storage = map[string]string{ "Type": "filestore", "Path": binPath, @@ -72,8 +73,8 @@ func (store FileStore) NewUpload(ctx context.Context, info handler.FileInfo) (ha upload := &fileUpload{ info: info, - infoPath: store.infoPath(id), - binPath: store.binPath(id), + infoPath: store.infoPath(info.ID), + binPath: binPath, } // writeInfo creates the file by itself if necessary