Skip to content

Commit

Permalink
Merge pull request #275 from nemunaire/f/initial_root
Browse files Browse the repository at this point in the history
Fix initial root file for new account
  • Loading branch information
nemunaire authored Feb 8, 2024
2 parents 3b8680c + 93095ef commit 3c9bd50
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 3c9bd50

Please sign in to comment.