Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[Fix] Handle case when existing metadata is null

Neeraj Gupta222887489820
diff --git a/server/pkg/controller/file.go b/server/pkg/controller/file.go
index 20a6c2d34c..f14ea34305 100644
--- a/server/pkg/controller/file.go
+++ b/server/pkg/controller/file.go
@@ -633,7 +633,10 @@ func (c *FileController) validateUpdateMetadataRequest(ctx *gin.Context, req ent
}).Error("can't update magic metadata for file which isn't owned by use")
return stacktrace.Propagate(ente.ErrPermissionDenied, "")
}
- oldToNewCountDiff := existingMetadata.Count - updateMMdRequest.MagicMetadata.Count
+ oldToNewCountDiff := 0
+ if existingMetadata != nil {
+ oldToNewCountDiff = existingMetadata.Count - updateMMdRequest.MagicMetadata.Count
+ }
// Return an error if there is a version mismatch with the previous metadata
// or if the new metadata contains an unexpectedly lower number of keys
// (oldToNewCountDiff difference is > 2), which may indicate potential data loss due to potentially buggy client.