From 25cedd5e2f8bb137754ee637c1bf8c31ea18e6a4 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta Date: Sat, 30 Mar 2024 15:24:52 +0530 Subject: [PATCH] [server] Gracefully handle stale collection entry (#1260) ## Description ## Tests --- server/pkg/controller/collection.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/pkg/controller/collection.go b/server/pkg/controller/collection.go index 6e51072ad..15c06fa33 100644 --- a/server/pkg/controller/collection.go +++ b/server/pkg/controller/collection.go @@ -488,6 +488,15 @@ func (c *CollectionController) GetDiffV2(ctx *gin.Context, cID int64, userID int if diff[idx].OwnerID != userID { diff[idx].MagicMetadata = 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 + log.WithFields(log.Fields{ + "file_id": diff[idx].ID, + "collection_id": cID, + "updated_at": diff[idx].UpdationTime, + }).Warning("stale collection_file found") + diff[idx].IsDeleted = true + } } return diff, hasMore, nil }