Skip to content

Commit

Permalink
If root file doesn't exists, this is because no file has been uploade…
Browse files Browse the repository at this point in the history
…d yet

Fixes: #270
  • Loading branch information
nemunaire committed Dec 21, 2023
1 parent e5daa61 commit 93095ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion internal/app/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/ddvk/rmfakecloud/internal/integrations"
"github.com/ddvk/rmfakecloud/internal/messages"
"github.com/ddvk/rmfakecloud/internal/storage"
"github.com/ddvk/rmfakecloud/internal/storage/fs"
"github.com/gin-gonic/gin"
"github.com/golang-jwt/jwt/v4"
"github.com/gorilla/websocket"
Expand Down Expand Up @@ -753,7 +754,13 @@ func (app *App) syncGetRootV3(c *gin.Context) {
uid := c.GetString(userIDKey)

reader, generation, _, err := app.blobStorer.LoadBlob(uid, "root")
if err != nil {
if err == fs.ErrorNotFound {
log.Warn("No root file found, assuming this is a new account")
c.JSON(http.StatusOK, messages.SyncRootV3{
Generation: 0,
})
return
} else if err != nil {
log.Error(err)
c.AbortWithStatus(http.StatusInternalServerError)
return
Expand Down
2 changes: 1 addition & 1 deletion internal/messages/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ type SyncCompletedRequestV2 struct {
// SyncRootV3
type SyncRootV3 struct {
Generation int64 `json:"generation"`
Hash string `json:"hash"`
Hash string `json:"hash,omitempty"`
}

// IntegrationsResponse integrations
Expand Down

0 comments on commit 93095ef

Please sign in to comment.