From 4161b5c2b4afc3cfc5e99531ca879fa8379f972a Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Sat, 19 Oct 2024 21:39:56 +0300 Subject: backend: actually fix download demo --- backend/handlers/record.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'backend/handlers') 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) { // Query drive instead of finding location id from db because SOMEONE reuploaded the demos. // Tbf I had to reupload and will have to do time after time. Fuck you Google. // I guess there's no need to store location id of demos anymore? - fileList, err := srv.Files.List().Q(fmt.Sprintf("name = '%s.dem'", uuid)).Do() + // ALSO ALSO, Google keeps track of old deleted files so sort by createdTime to get the latest demo. + fileList, err := srv.Files.List().Q(fmt.Sprintf("name = '%s.dem'", uuid)). + Fields("files(id, name, createdTime)").OrderBy("createdTime desc").PageSize(1).Do() if err != nil { c.JSON(http.StatusOK, models.ErrorResponse(err.Error())) return } + log.Printf("found %d files", len(fileList.Files)) + for _, f := range fileList.Files { + log.Printf("%+v", f) + } if len(fileList.Files) == 0 { c.JSON(http.StatusOK, models.ErrorResponse("Demo not found.")) return -- cgit v1.2.3