filestore: keep ID passed to NewUpload, if available (#820)

* fix(filestore): keep info.ID

* fix
This commit is contained in:
genofire 2022-10-02 00:25:40 +02:00 committed by GitHub
parent f0b63f4371
commit 306a031953
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -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