Skip to content

armgit / ente

Public Imported from GitHub
0

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

Simpfiy

Neeraj Gupta74de796c7189
diff --git a/server/cmd/museum/main.go b/server/cmd/museum/main.go
index fccc7c07a4..59942112bc 100644
--- a/server/cmd/museum/main.go
+++ b/server/cmd/museum/main.go
@@ -965,16 +965,6 @@ func setupAndStartCrons(userAuthRepo *repo.UserAuthRepository, collectionLinkRep
_ = userAuthRepo.RemoveExpiredOTTs()
})
- schedule(c, "@every 10m", func() {
- // Clean up fake SRP sessions older than 1 hour (3600 seconds = 3600000000 microseconds)
- deleted, err := userAuthRepo.CleanupOldFakeSessions(context.Background(), 3600000000)
- if err != nil {
- log.WithError(err).Error("Failed to cleanup old fake SRP sessions")
- } else if deleted > 0 {
- log.WithField("count", deleted).Info("Cleaned up old fake SRP sessions")
- }
- })
-
schedule(c, "@every 24h", func() {
_ = userAuthRepo.RemoveDeletedTokens(timeUtil.MicrosecondsBeforeDays(30))
_ = castDb.DeleteOldSessions(context.Background(), timeUtil.MicrosecondsBeforeDays(7))
@@ -1055,6 +1045,12 @@ func setupAndStartCrons(userAuthRepo *repo.UserAuthRepository, collectionLinkRep
scheduleAndRun(c, "@every 24h", func() {
emailNotificationCtrl.NudgePaidSubscriberForFamily()
+ deleted, err := userAuthRepo.CleanupOldFakeSessions(context.Background())
+ if err != nil {
+ log.WithError(err).Error("Failed to cleanup old fake SRP sessions")
+ } else if deleted > 0 {
+ log.WithField("count", deleted).Info("Cleaned up old fake SRP sessions")
+ }
})
schedule(c, "@every 1m", func() {
diff --git a/server/pkg/repo/srp.go b/server/pkg/repo/srp.go
index 4dbe220460..df485a4842 100644
--- a/server/pkg/repo/srp.go
+++ b/server/pkg/repo/srp.go
@@ -183,13 +183,12 @@ func (repo *UserAuthRepository) SetSrpSessionVerified(ctx context.Context, sessi
}
// CleanupOldFakeSessions removes fake sessions older than the specified duration
-func (repo *UserAuthRepository) CleanupOldFakeSessions(ctx context.Context, olderThan int64) (int64, error) {
+func (repo *UserAuthRepository) CleanupOldFakeSessions(ctx context.Context) (int64, error) {
// Delete fake sessions older than specified microseconds
result, err := repo.DB.ExecContext(ctx, `
DELETE FROM srp_sessions
WHERE is_fake = true
- AND created_at < (now_utc_micro_seconds() - $1)`,
- olderThan)
+ AND created_at < (now_utc_micro_seconds() - (24::BIGINT * 60 * 60 * 1000 * 1000))`)
if err != nil {
return 0, stacktrace.Propagate(err, "failed to cleanup old fake sessions")
}