Skip to content

armgit / ente

Public Imported from GitHub
0

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

[server] Add missing check for stale file entries

Neeraj Gupta47c12251ae3f
diff --git a/server/pkg/controller/collections/cast.go b/server/pkg/controller/collections/cast.go
index 1c8525e278..b1f6980a6b 100644
--- a/server/pkg/controller/collections/cast.go
+++ b/server/pkg/controller/collections/cast.go
@@ -47,6 +47,14 @@ func (c *CollectionController) GetCastDiff(ctx *gin.Context, sinceTime int64) ([
}
diff[idx].Action = nil
diff[idx].ActionUserID = nil
+ if diff[idx].Metadata.EncryptedData == "-" && !diff[idx].IsDeleted {
+ // This indicates that the file is deleted, but we still have a stale entry in the collection
+ reqContextLogger.WithFields(log.Fields{
+ "file_id": diff[idx].ID,
+ "updated_at": diff[idx].UpdationTime,
+ }).Warning("stale collection_file found")
+ diff[idx].IsDeleted = true
+ }
}
return diff, hasMore, nil
}
diff --git a/server/pkg/controller/collections/share.go b/server/pkg/controller/collections/share.go
index 81cdc8111e..3e9206e778 100644
--- a/server/pkg/controller/collections/share.go
+++ b/server/pkg/controller/collections/share.go
@@ -318,6 +318,14 @@ func (c *CollectionController) GetPublicDiff(ctx *gin.Context, sinceTime int64)
}
diff[idx].Action = nil
diff[idx].ActionUserID = nil
+ if diff[idx].Metadata.EncryptedData == "-" && !diff[idx].IsDeleted {
+ // This indicates that the file is deleted, but we still have a stale entry in the collection
+ reqContextLogger.WithFields(log.Fields{
+ "file_id": diff[idx].ID,
+ "updated_at": diff[idx].UpdationTime,
+ }).Warning("stale collection_file found")
+ diff[idx].IsDeleted = true
+ }
}
return diff, hasMore, nil
}