π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Retry file count initialization after stale cleanup
Neeraj Gupta9f2f1b40007f
diff --git a/server/pkg/controller/usage_file_count_init.go b/server/pkg/controller/usage_file_count_init.goindex e325de5c97..828a0a64f7 100644--- a/server/pkg/controller/usage_file_count_init.go+++ b/server/pkg/controller/usage_file_count_init.go@@ -91,8 +91,10 @@ func (c *FileCountInitializer) initializeUser(userID int64) bool {log.WithError(cleanupErr).WithField("user_id", userID).Error("Failed to find stale deleted file memberships")}cleaned := false+ retryNow := len(fileIDs) < repo.StaleDeletedFileLimitfor _, fileID := range fileIDs {if cleanupErr := c.TrashRepo.CleanUpDeletedFilesFromCollection(ctx, []int64{fileID}, userID); cleanupErr != nil {+ retryNow = falselog.WithError(cleanupErr).WithFields(log.Fields{"user_id": userID,"file_id": fileID,@@ -101,8 +103,15 @@ func (c *FileCountInitializer) initializeUser(userID int64) bool {cleaned = true}}+ if !cleaned || !retryNow {+ log.WithError(err).WithField("user_id", userID).Warn("File count initialization ineligible")+ return cleaned+ }+ initialized, err = c.UsageRepo.InitializeFileCounts(ctx, userID)+ }+ if errors.Is(err, repo.ErrFileCountIneligible) {log.WithError(err).WithField("user_id", userID).Warn("File count initialization ineligible")- return cleaned+ return false}if err != nil {log.WithError(err).WithField("user_id", userID).Error("Failed to initialize file counts")diff --git a/server/pkg/repo/trash.go b/server/pkg/repo/trash.goindex ff278c2906..e45c8e9b39 100644--- a/server/pkg/repo/trash.go+++ b/server/pkg/repo/trash.go@@ -20,7 +20,7 @@ const (TrashDiffLimit = 2500TrashBatchSize = 1000- staleDeletedFileLimit = 10+ StaleDeletedFileLimit = 10EmptyTrashQueueItemSeparator = "::")@@ -253,7 +253,7 @@ func (t *TrashRepository) GetStaleDeletedFileIDs(ctx context.Context, userID intJOIN trash t ON t.file_id = f.file_idWHERE c.owner_id = $1 AND f.owner_id = $1 AND t.user_id = $1AND t.is_deleted = TRUE AND t.is_restored = FALSE- LIMIT $2`, userID, staleDeletedFileLimit)+ LIMIT $2`, userID, StaleDeletedFileLimit)if err != nil {return nil, stacktrace.Propagate(err, "")}