diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-10-19 21:39:56 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-10-19 21:39:56 +0300 |
| commit | 4161b5c2b4afc3cfc5e99531ca879fa8379f972a (patch) | |
| tree | cb72ed841a91a80ef612f3d2ebfd684b9b5fd6ff | |
| parent | backend: fix download demo (diff) | |
| download | lphub-4161b5c2b4afc3cfc5e99531ca879fa8379f972a.tar.gz lphub-4161b5c2b4afc3cfc5e99531ca879fa8379f972a.tar.bz2 lphub-4161b5c2b4afc3cfc5e99531ca879fa8379f972a.zip | |
backend: actually fix download demo
| -rw-r--r-- | backend/handlers/record.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/backend/handlers/record.go b/backend/handlers/record.go index 6078f8d..25d0509 100644 --- a/backend/handlers/record.go +++ b/backend/handlers/record.go | |||
| @@ -369,11 +369,17 @@ func DownloadDemoWithID(c *gin.Context) { | |||
| 369 | // Query drive instead of finding location id from db because SOMEONE reuploaded the demos. | 369 | // Query drive instead of finding location id from db because SOMEONE reuploaded the demos. |
| 370 | // Tbf I had to reupload and will have to do time after time. Fuck you Google. | 370 | // Tbf I had to reupload and will have to do time after time. Fuck you Google. |
| 371 | // I guess there's no need to store location id of demos anymore? | 371 | // I guess there's no need to store location id of demos anymore? |
| 372 | fileList, err := srv.Files.List().Q(fmt.Sprintf("name = '%s.dem'", uuid)).Do() | 372 | // ALSO ALSO, Google keeps track of old deleted files so sort by createdTime to get the latest demo. |
| 373 | fileList, err := srv.Files.List().Q(fmt.Sprintf("name = '%s.dem'", uuid)). | ||
| 374 | Fields("files(id, name, createdTime)").OrderBy("createdTime desc").PageSize(1).Do() | ||
| 373 | if err != nil { | 375 | if err != nil { |
| 374 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) | 376 | c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) |
| 375 | return | 377 | return |
| 376 | } | 378 | } |
| 379 | log.Printf("found %d files", len(fileList.Files)) | ||
| 380 | for _, f := range fileList.Files { | ||
| 381 | log.Printf("%+v", f) | ||
| 382 | } | ||
| 377 | if len(fileList.Files) == 0 { | 383 | if len(fileList.Files) == 0 { |
| 378 | c.JSON(http.StatusOK, models.ErrorResponse("Demo not found.")) | 384 | c.JSON(http.StatusOK, models.ErrorResponse("Demo not found.")) |
| 379 | return | 385 | return |