Skip to content

Commit 44d12bf

Browse files
committed
Change file owner to API caller on /files/duplicate, fixed openapi.json
1 parent 4286d75 commit 44d12bf

File tree

4 files changed

+561
-369
lines changed

4 files changed

+561
-369
lines changed

internal/storage/FileServing.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ func DuplicateFile(file models.File, parametersToChange int, newFileName string,
426426

427427
newFile.Id = createNewId()
428428
newFile.DownloadCount = 0
429+
newFile.UserId = fileParameters.UserId
429430
AddHotlink(&newFile)
430431

431432
database.SaveMetaData(newFile)

internal/webserver/api/Api.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,15 @@ func apiDuplicateFile(w http.ResponseWriter, r requestParser, user models.User)
483483
sendError(w, http.StatusUnauthorized, "No permission to duplicate this file")
484484
return
485485
}
486-
uploadRequest := fileupload.CreateUploadConfig(request.AllowedDownloads,
486+
uploadConfig := fileupload.CreateUploadConfig(request.AllowedDownloads,
487487
request.ExpiryDays,
488488
request.Password,
489489
request.UnlimitedTime,
490490
request.UnlimitedDownloads,
491491
false, // is not being used by storage.DuplicateFile
492-
0) // is not being used by storage.DuplicateFile
493-
newFile, err := storage.DuplicateFile(file, request.RequestedChanges, request.FileName, uploadRequest)
492+
0) // is not being used by storage.DuplicateFile
493+
uploadConfig.UserId = user.Id
494+
newFile, err := storage.DuplicateFile(file, request.RequestedChanges, request.FileName, uploadConfig)
494495
if err != nil {
495496
sendError(w, http.StatusInternalServerError, err.Error())
496497
return

0 commit comments

Comments
 (0)