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 Nov 27, 2023
1 parent 15be8b7 commit 71edeb4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 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,12 @@ 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 {
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 71edeb4

Please sign in to comment.