π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Prune server file and collection comments
Manav Rathic695d4732ec5
diff --git a/server/ente/collection.go b/server/ente/collection.goindex 0ccb04eaff..baae8d77ca 100644--- a/server/ente/collection.go+++ b/server/ente/collection.go@@ -27,8 +27,7 @@ type Collection struct {MagicMetadata *MagicMetadata `json:"magicMetadata,omitempty"`App string `json:"app"`PublicMagicMetadata *MagicMetadata `json:"pubMagicMetadata,omitempty"`- // SharedMagicMetadata keeps the metadata of the sharees to store settings like- // if the collection should be shown on timeline or not+ // Per-sharee settings such as timeline visibility.SharedMagicMetadata *MagicMetadata `json:"sharedMagicMetadata,omitempty"`}@@ -160,21 +159,16 @@ type CopyResponse struct {}type RemoveFilesRequest struct {- CollectionID int64 `json:"collectionID" binding:"required"`- // OtherFileIDs represents the files which don't belong the user trying to remove files- FileIDs []int64 `json:"fileIDs"`+ CollectionID int64 `json:"collectionID" binding:"required"`+ FileIDs []int64 `json:"fileIDs"`}-// In V3, only those files are allowed to be removed from collection which don't belong to the collection owner.-// If collection owner wants to remove files owned by them, the client should move those files to other collections-// owned by the collection user. Also, See [Collection Delete Versions] for additional context.+// Files owned by the collection owner must be moved, not removed.type RemoveFilesV3Request struct {- CollectionID int64 `json:"collectionID" binding:"required"`- // OtherFileIDs represents the files which don't belong the user trying to remove files- FileIDs []int64 `json:"fileIDs" binding:"required"`+ CollectionID int64 `json:"collectionID" binding:"required"`+ FileIDs []int64 `json:"fileIDs" binding:"required"`}-// Only collection owner or admins can suggest deletion for files owned by others (not the acting user).type SuggestDeleteRequest struct {CollectionID int64 `json:"collectionID" binding:"required"`FileIDs []int64 `json:"fileIDs" binding:"required"`diff --git a/server/ente/file.go b/server/ente/file.goindex 2d2f5e054a..b84f09d438 100644--- a/server/ente/file.go+++ b/server/ente/file.go@@ -18,7 +18,7 @@ type File struct {File FileAttributes `json:"file" binding:"required"`Thumbnail FileAttributes `json:"thumbnail" binding:"required"`Metadata FileAttributes `json:"metadata" binding:"required"`- // IsDeleted is True when the file ID is removed from the CollectionID+ // True when the file was removed from this collection.IsDeleted bool `json:"isDeleted"`UpdationTime int64 `json:"updationTime"`MagicMetadata *MagicMetadata `json:"magicMetadata,omitempty"`@@ -36,7 +36,7 @@ type MetaFile struct {EncryptedKey string `json:"encryptedKey"`KeyDecryptionNonce string `json:"keyDecryptionNonce"`Metadata FileAttributes `json:"metadata" binding:"required"`- // IsDeleted is True when the file ID is removed from the CollectionID+ // True when the file was removed from this collection.IsDeleted bool `json:"isDeleted"`UpdationTime int64 `json:"updationTime"`MagicMetadata *MagicMetadata `json:"magicMetadata,omitempty"`@@ -81,13 +81,12 @@ type FilesInfoResponse struct {}type TrashRequest struct {- OwnerID int64 // ownerID will be set internally via auth header+ OwnerID int64 // Set from the authenticated user, not the request body.TrashItems []TrashItemRequest `json:"items" binding:"required"`}type TrashItemRequest struct {- FileID int64 `json:"fileID" binding:"required"`- // collectionID belonging to same owner+ FileID int64 `json:"fileID" binding:"required"`CollectionID int64 `json:"collectionID" binding:"required"`}diff --git a/server/pkg/controller/collections/collection.go b/server/pkg/controller/collections/collection.goindex a75e5a1559..5f45fe0c9f 100644--- a/server/pkg/controller/collections/collection.go+++ b/server/pkg/controller/collections/collection.go@@ -47,7 +47,7 @@ func (c *CollectionController) Create(collection ente.Collection, ownerID int64)if err := validateOwnedCollectionKey(collection.EncryptedKey, collection.KeyDecryptionNonce); err != nil {return ente.Collection{}, err}- // The key attribute check is to ensure that user does not end up uploading any files before actually setting the key attributes.+ // Do not allow uploads before the user has configured key attributes.if _, keyErr := c.UserRepo.GetKeyAttributes(ownerID); keyErr != nil {return ente.Collection{}, stacktrace.Propagate(keyErr, "Unable to get keyAttributes")}@@ -169,7 +169,6 @@ func (c *CollectionController) TrashV3(ctx *gin.Context, req ente.TrashCollectioif err != nil {return stacktrace.Propagate(err, "failed to revoke cast token")}- // Continue with current delete flow till. This disables sharing for this collection and then queue it up for deletionerr = c.CollectionRepo.ScheduleDelete(cID)if err != nil {return stacktrace.Propagate(err, "")diff --git a/server/pkg/controller/collections/share.go b/server/pkg/controller/collections/share.goindex 92e3eafe9e..1ce571cd83 100644--- a/server/pkg/controller/collections/share.go+++ b/server/pkg/controller/collections/share.go@@ -566,7 +566,7 @@ func (c *CollectionController) GetPublicDiff(ctx *gin.Context, sinceTime int64)if err != nil {return nil, false, stacktrace.Propagate(err, "")}- // hide private metadata before returning files info in diff+ // Don't expose private metadata in a public diff.for idx := range diff {if diff[idx].MagicMetadata != nil {diff[idx].MagicMetadata = nil@@ -580,7 +580,7 @@ func (c *CollectionController) GetPublicDiff(ctx *gin.Context, sinceTime int64)diff[idx].Action = nildiff[idx].ActionUserID = nilif diff[idx].Metadata.EncryptedData == "-" && !diff[idx].IsDeleted {- // This indicates that the file is deleted, but we still have a stale entry in the collection+ // "-" marks a deleted file whose collection entry is stale.reqContextLogger.WithFields(log.Fields{"file_id": diff[idx].ID,"updated_at": diff[idx].UpdationTime,diff --git a/server/pkg/controller/file.go b/server/pkg/controller/file.goindex 93c5c8a2a1..2a89218510 100644--- a/server/pkg/controller/file.go+++ b/server/pkg/controller/file.go@@ -127,8 +127,7 @@ func (c *FileController) validateFileCreateOrUpdateReq(userID int64, file ente.Fif ente.App(collection.App) != app {return stacktrace.Propagate(ente.ErrInvalidApp, "ctx app is different from collection app=%s collectionApp=%s", app, collection.App)}- // Verify that user owns the collection.- // Warning: Do not remove this check+ // Creating a file requires collection ownership, not shared access.if collection.Owner.ID != userID {return stacktrace.Propagate(ente.ErrPermissionDenied, "collection doesn't belong to user")}@@ -304,13 +303,8 @@ func (c *FileController) Update(ctx context.Context, userID int64, file ente.Filif err != nil {return response, stacktrace.Propagate(err, "")}- // The client might retry updating the same file accidentally.- //- // This usually happens on iOS, where the first request to update a file- // might succeed, but the client might go into the background before it gets- // to know of it, and then retries again.- //- // As a safety check, also compare the file sizes.+ // iOS may retry after backgrounding before receiving a successful response.+ // Only matching object keys and total size make the update a duplicate.isDuplicateRequest := falseif existingThumbnailObjectKey == file.Thumbnail.ObjectKey &&existingFileObjectKey == file.File.ObjectKey &&@@ -319,11 +313,9 @@ func (c *FileController) Update(ctx context.Context, userID int64, file ente.Fil}oldObjects := make([]string, 0)if existingThumbnailObjectKey != file.Thumbnail.ObjectKey {- // Ignore accidental retrialsoldObjects = append(oldObjects, existingThumbnailObjectKey)}if existingFileObjectKey != file.File.ObjectKey {- // Ignore accidental retrialsoldObjects = append(oldObjects, existingFileObjectKey)}if file.Info != nil {@@ -377,7 +369,6 @@ func (c *FileController) ValidateUploadEligibility(ctx context.Context, userID ireturn nil}-// GetUploadURLWithMetadata returns a single presigned URL that enforces checksum & lengthfunc (c *FileController) GetUploadURLWithMetadata(ctx context.Context, userID int64, req ente.UploadURLRequest, app ente.App) (ente.UploadURL, error) {if req.ContentLength <= 0 {return ente.UploadURL{}, stacktrace.Propagate(ente.ErrBadRequest, "contentLength must be greater than 0")@@ -465,8 +456,7 @@ func (c *FileController) DoesFileExistInCollection(ctx *gin.Context, fileID int6return nil}-// GetSignedURLForPublicFile returns a presigned URL for a file without access checking.-// The caller is responsible for verifying access before calling this method.+// The caller must verify access before using this method.func (c *FileController) GetSignedURLForPublicFile(ctx *gin.Context, fileID int64, objType ente.ObjectType) (string, error) {return c.getSignedURLForType(ctx, fileID, objType)}@@ -566,8 +556,6 @@ func isCliRequest(ctx *gin.Context) bool {return strings.Contains(userAgent, "go-resty")}-// getWasabiSignedUrlIfAvailable returns a signed URL for the given fileID and objectType. It prefers wasabi over b2-// if the file is not found in wasabi, it will return signed url from B2func (c *FileController) getWasabiSignedUrlIfAvailable(fileID int64, objType ente.ObjectType) (string, error) {s3Object, dcs, err := c.ObjectRepo.GetObjectWithDCs(fileID, objType)if err != nil {@@ -631,10 +619,6 @@ func (c *FileController) GetFileInfo(ctx *gin.Context, userID int64, fileIDs []iif err != nil {return nil, stacktrace.Propagate(err, "")}- // Use GetFilesInfo for get fileInfo for the given list.- // Then for fileIDs that are not present in the response of GetFilesInfo, use GetFileInfoFromObjectKeys to get the file info.- // and merge the two responses. and for the fileIDs that are not present in the response of GetFileInfoFromObjectKeys,- // add a new FileInfo entry with size = -1fileInfoResponse, err := c.FileRepo.GetFilesInfo(ctx, fileIDs, userID)if err != nil {return nil, stacktrace.Propagate(err, "")@@ -676,8 +660,7 @@ func (c *FileController) GetFileInfo(ctx *gin.Context, userID int64, fileIDs []iid := fileIDfileInfo := fileInfoResponse[id]if fileInfo == nil {- // This should be happening only for older users who may have a stale- // collection_file entry for a file that user has deleted+ // Old accounts may retain collection entries for deleted files.log.WithField("fileID", id).Error("fileInfo not found")fileInfoList = append(fileInfoList, &ente.FileInfoResponse{ID: id,@@ -808,9 +791,7 @@ func (c *FileController) validateUpdateMetadataRequest(ctx *gin.Context, req entif 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.+ // Reject version mismatches and large key-count drops to avoid data loss.if existingMetadata != nil && (existingMetadata.Version != updateMMdRequest.MagicMetadata.Version || oldToNewCountDiff > 2) {log.WithFields(log.Fields{"existing_count": existingMetadata.Count,@@ -826,8 +807,6 @@ func (c *FileController) validateUpdateMetadataRequest(ctx *gin.Context, req entreturn nil}-// CleanupDeletedFiles deletes the files from object store. It will delete from both hot storage and-// cold storage (if replicated)func (c *FileController) CleanupDeletedFiles() {log.Info("Cleaning up deleted files")if c.cleanupCronRunning {@@ -1168,7 +1147,6 @@ func (c *FileController) GetMultipartUploadURLs(ctx context.Context, userID int6return multipartUploadURLs, nil}-// GetMultipartUploadURLWithMetadata enforces content length and optional per-part checksums.func (c *FileController) GetMultipartUploadURLWithMetadata(ctx context.Context, userID int64, req ente.MultipartUploadURLRequest, app ente.App) (ente.MultipartUploadURLs, error) {if req.ContentLength <= 0 {return ente.MultipartUploadURLs{}, stacktrace.Propagate(ente.ErrBadRequest, "contentLength must be greater than 0")diff --git a/server/pkg/controller/file_copy/file_copy.go b/server/pkg/controller/file_copy/file_copy.goindex 8be4e5a594..c1caa8fdb1 100644--- a/server/pkg/controller/file_copy/file_copy.go+++ b/server/pkg/controller/file_copy/file_copy.go@@ -81,7 +81,7 @@ func (fc *FileCopyController) CopyFiles(c *gin.Context, req ente.CopyFileSyncReqif err != nil {return nil, err}- // note: this assumes that preview existingFilesToCopy for videos are not tracked inside the object_keys table+ // Video previews are not tracked in object_keys.if len(s3ObjectsToCopy) != 2*len(fileIDs) {return nil, ente.NewInternalError(fmt.Sprintf("expected %d objects, got %d", 2*len(fileIDs), len(s3ObjectsToCopy)))}@@ -92,7 +92,7 @@ func (fc *FileCopyController) CopyFiles(c *gin.Context, req ente.CopyFileSyncReq}logger.WithField("totalSize", totalSize).Info("total size of existingFilesToCopy to copy")- // request the uploadUrls using existing method. This is to ensure that orphan objects are automatically cleaned up+ // Reuse upload URLs so abandoned copies are cleaned up as orphan objects.// todo:(neeraj) optimize this method by removing the need for getting a signed url for each objectuploadUrls, err := fc.FileController.GetUploadURLs(c, userID, len(s3ObjectsToCopy), app, true)if err != nil {diff --git a/server/pkg/controller/lock/lock.go b/server/pkg/controller/lock/lock.goindex b6bf609b43..82ecf495a8 100644--- a/server/pkg/controller/lock/lock.go+++ b/server/pkg/controller/lock/lock.go@@ -13,17 +13,7 @@ type LockController struct {HostName string}-// Try to obtain a lock with the given lockID.-//-// Return false if the lock is already taken.-//-// A call to this function should be matched by a call to ReleaseLock. A common-// pattern is to put the ReleaseLock into a defer statement immediately-// following the lock acquisition.-//-// However, it is also fine to omit the release. Such would be useful for cases-// where we want to ensure the same job cannot run again until the expiry time-// is past.+// Leaving a lock unreleased prevents another run until it expires.func (c *LockController) TryLock(lockID string, lockUntil int64) bool {lockStatus, err := c.TaskLockingRepo.AcquireLock(lockID, lockUntil, c.HostName)if err != nil || !lockStatus {@@ -32,11 +22,7 @@ func (c *LockController) TryLock(lockID string, lockUntil int64) bool {return true}-// ExtendLock refreshes an existing lock by updating its locked_at to now and-// extending its lockUntil.-//-// It is only valid to call this method when holding an existing lock previously-// obtained using TryLock.+// Only the host holding a lock can extend it.func (c *LockController) ExtendLock(lockID string, lockUntil int64) error {foundLock, err := c.TaskLockingRepo.ExtendLock(lockID, lockUntil, c.HostName)if err != nil {diff --git a/server/pkg/controller/mailing_lists.go b/server/pkg/controller/mailing_lists.goindex 6983a2fe4d..6b70c9a3b7 100644--- a/server/pkg/controller/mailing_lists.go+++ b/server/pkg/controller/mailing_lists.go@@ -77,11 +77,7 @@ func (c *MailingListsController) listmonkSubscribe(email string) error {}func (c *MailingListsController) listmonkUnsubscribe(email string) error {- // Listmonk doesn't provide an endpoint for unsubscribing users- // from a particular list directly via their email- //- // Thus, fetching subscriberID through email address,- // and then calling the endpoint to delete that user+ // Listmonk deletion needs a subscriber ID, so look it up by email first.id, err := listmonk.GetSubscriberID(c.listmonkCredentials.BaseURL+"/api/subscribers",c.listmonkCredentials.Username, c.listmonkCredentials.Password, email)if err != nil {diff --git a/server/pkg/controller/object.go b/server/pkg/controller/object.goindex 597bdf0b4b..12698fae93 100644--- a/server/pkg/controller/object.go+++ b/server/pkg/controller/object.go@@ -14,15 +14,6 @@ import (log "github.com/sirupsen/logrus")-// ObjectController manages various operations specific to object storage,-// including dealing with the special cases for individual replicas.-//-// The user's encrypted data is replicated to three places - 2 hot storage data-// centers, and 1 cold storage. All three of them provide S3 compatible APIs-// that we use to add and remove objects. However, there are still some specific-// (and intentional) differences in the way the three replicas work. e.g.-// objects stored in Wasabi are also placed under a special compliance mode,-// which is a Wasabi specific feature.type ObjectController struct {S3Config *s3config.S3ConfigObjectRepo *repo.ObjectRepository@@ -35,12 +26,7 @@ const (RemoveComplianceHoldsLock = "remove_compliance_holds_lock")-// RemoveComplianceHolds removes the Wasabi compliance hold from objects in-// Wasabi for files which have been deleted.-//-// Removing the compliance hold will allow these files to then be deleted when-// we subsequently attempt to delete the objects from Wasabi after-// DeleteObjectQueue delay (x days currently).+// Wasabi objects cannot be deleted until their compliance hold is removed.func (c *ObjectController) RemoveComplianceHolds() {if c.S3Config.WasabiComplianceDC() == "" {return@@ -123,9 +109,6 @@ func (c *ObjectController) removeComplianceHold(qItem repo.QueueItem) {}}-// DisableObjectConditionalHold disables the Wasabi compliance conditional hold-// that has been placed on object. This way, we can enable these objects to be-// cleaned up when the user permanently deletes them.func (c *ObjectController) DisableObjectConditionalHold(s3Client *s3.S3, bucket string, objectKey string) error {_, err := wasabi.PutObjectCompliance(s3Client, &wasabi.PutObjectComplianceInput{Bucket: aws.String(bucket),diff --git a/server/pkg/controller/public/collection_link.go b/server/pkg/controller/public/collection_link.goindex 6d07fc4968..528de1ba01 100644--- a/server/pkg/controller/public/collection_link.go+++ b/server/pkg/controller/public/collection_link.go@@ -22,8 +22,7 @@ import (const (AccessTokenLength = 10- // DeviceLimitThreshold represents number of unique devices which can access a shared collection. (ip + user agent)- // is treated as unique device+ // A device is identified by its IP and user agent.DeviceLimitThreshold = 50DeviceLimitThresholdMultiplier = 10@@ -99,7 +98,7 @@ func (c *CollectionLinkController) CreateFile(ctx *gin.Context, file ente.File,return ente.File{}, stacktrace.Propagate(err, "")}collectionOwnerID := collection.Owner.ID- // Do not let any update happen via public Url+ // Don't allow public links to update files.file.ID = 0file.OwnerID = collectionOwnerIDfile.UpdationTime = time.Microseconds()@@ -180,10 +179,7 @@ func (c *CollectionLinkController) UpdateSharedUrl(ctx *gin.Context, req ente.Up}, nil}-// VerifyPassword verifies if the user has provided correct pw hash. If yes, it returns a signed jwt token which can be-// used by the client to pass in other requests for public collection.-// Having a separate endpoint for password validation allows us to easily rate-limit the attempts for brute-force-// attack for guessing password.+// Password verification is separate so attempts can be rate-limited.func (c *CollectionLinkController) VerifyPassword(ctx *gin.Context, req ente.VerifyPasswordRequest) (*ente.VerifyPasswordResponse, error) {accessContext := auth.MustGetPublicAccessContext(ctx)collectionLinkRow, err := c.CollectionLinkRepo.GetActiveCollectionLinkRow(ctx, accessContext.CollectionID)@@ -222,7 +218,7 @@ func (c *CollectionLinkController) GetPublicCollection(ctx *gin.Context, mustAllif collection.IsDeleted {return ente.Collection{}, stacktrace.Propagate(ente.ErrNotFound, "collection is deleted")}- // hide redundant/private information+ // Don't expose private collection metadata through public links.collection.Sharees = nilcollection.MagicMetadata = nilpublicURLsWithLimitedInfo := make([]ente.PublicURL, 0)diff --git a/server/pkg/controller/public/file_link.go b/server/pkg/controller/public/file_link.goindex 7a422dcc08..5f366af9b4 100644--- a/server/pkg/controller/public/file_link.go+++ b/server/pkg/controller/public/file_link.go@@ -50,7 +50,6 @@ func (c *FileLinkController) CreateLink(ctx *gin.Context, req ente.CreateFileUrlif updateErr != nil {return nil, stacktrace.Propagate(updateErr, "failed to update link secret")}- // Re-fetch to include any values that might have been updated.row, rowErr = c.FileLinkRepo.GetFileUrlRowByFileID(ctx, req.FileID)if rowErr != nil {return nil, stacktrace.Propagate(rowErr, "failed to get active file url token after updating secret")@@ -149,10 +148,7 @@ func (c *FileLinkController) PassInfo(ctx *gin.Context) (*ente.FileLinkRow, erroreturn c.FileLinkRepo.GetFileUrlRowByFileID(ctx, accessContext.FileID)}-// VerifyPassword verifies if the user has provided correct pw hash. If yes, it returns a signed jwt token which can be-// used by the client to pass in other requests for public collection.-// Having a separate endpoint for password validation allows us to easily rate-limit the attempts for brute-force-// attack for guessing password.+// Password verification is separate so attempts can be rate-limited.func (c *FileLinkController) VerifyPassword(ctx *gin.Context, req ente.VerifyPasswordRequest) (*ente.VerifyPasswordResponse, error) {accessContext := auth.MustGetFileLinkAccessContext(ctx)collectionLinkRow, err := c.FileLinkRepo.GetActiveFileUrlToken(ctx, accessContext.FileID)diff --git a/server/pkg/repo/collection.go b/server/pkg/repo/collection.goindex fd48222a67..3d9198156a 100644--- a/server/pkg/repo/collection.go+++ b/server/pkg/repo/collection.go@@ -86,8 +86,6 @@ func (repo *CollectionRepository) Get(collectionID int64) (ente.Collection, erroreturn c, nil}-// GetWithSharingDetailsForUser returns the collection along with sharees, active public URLs,-// and decrypted owner email. If the actor is a sharee, the encrypted key sealed for that actor is returned.func (repo *CollectionRepository) GetWithSharingDetailsForUser(collectionID int64, actorUserID int64) (ente.Collection, error) {c, err := repo.Get(collectionID)if err != nil {@@ -290,7 +288,8 @@ func (repo *CollectionRepository) GetCollectionsSharedWithUser(userID int64, updc.EncryptedName = encryptedName.Stringc.NameDecryptionNonce = nameDecryptionNonce.String}- // if collection is unshared, no need to parse owner's email. Email decryption will fail if the owner's account is deleted+ // Unshared collections appear deleted, and their former owner's email may+ // no longer be decryptable.if c.IsDeleted {c.Owner.Email = ""} else {@@ -302,8 +301,7 @@ func (repo *CollectionRepository) GetCollectionsSharedWithUser(userID int64, upd}// TODO: Pull this information in the previous queryif c.IsDeleted {- // if collection is deleted or unshared, c.IsDeleted will be true. In both cases, we should not send- // back information about other sharees+ // Don't expose other sharees after deletion or unsharing.c.Sharees = make([]ente.CollectionUser, 0)} else {sharees, err := repo.GetSharees(c.ID)@@ -774,15 +772,12 @@ func (repo *CollectionRepository) RestoreFiles(ctx context.Context, userID int64return tx.Commit()}-// RemoveFilesV3 just remove the entries from the collection. This method assume that collection owner is-// different from the file ownersfunc (repo *CollectionRepository) RemoveFilesV3(context context.Context, collectionID int64, collectionOwnerID int64, fileIDs []int64) error {updationTime := time.Microseconds()ownerToFileIDs, err := repo.FileRepo.GetOwnerToFileIDsMap(context, fileIDs)if err != nil {return stacktrace.Propagate(err, "")}- // verify that none of the file belongs to the collection ownerif _, ok := ownerToFileIDs[collectionOwnerID]; ok {return errors.New("can not remove files owned by album owner")}@@ -808,8 +803,6 @@ func (repo *CollectionRepository) RemoveFilesV3(context context.Context, collectreturn stacktrace.Propagate(err, "")}-// SuggestAction sets action markers for the given files in the collection so that-// clients can act on them. It does not mark the membership as deleted.func (repo *CollectionRepository) SuggestAction(ctx context.Context, collectionID int64, actorUserID int64, fileIDs []int64, action string) error {if len(fileIDs) == 0 {return nil@@ -1094,9 +1087,6 @@ func (repo *CollectionRepository) removeAllFilesAddedByOthers(collectionID int64return int64(len(fileIDs)), nil}-// ScheduleDelete marks the collection as deleted and queue up an operation to-// move the collection files to user's trash.-// See [Collection Delete Versions] for more detailsfunc (repo *CollectionRepository) ScheduleDelete(collectionID int64) error {updationTime := time.Microseconds()ctx := context.Background()diff --git a/server/pkg/repo/public/collection_link.go b/server/pkg/repo/public/collection_link.goindex 0a72d68673..a0ac06a818 100644--- a/server/pkg/repo/public/collection_link.go+++ b/server/pkg/repo/public/collection_link.go@@ -43,7 +43,6 @@ func (pcr *CollectionLinkRepo) GetAlbumUrl(app ente.App, token string) string {func (pcr *CollectionLinkRepo) Insert(ctx context.Context,cID int64, token string, validTill int64, deviceLimit int, enableCollect bool, enableComment bool, enableJoin *bool) error {- // default value for enableJoin is truejoin := trueif enableJoin != nil {join = *enableJoin@@ -80,8 +79,7 @@ func (pcr *CollectionLinkRepo) DisableSharing(ctx context.Context, cID int64) erreturn stacktrace.Propagate(err, "failed to disable sharing")}-// GetCollectionToActivePublicURLMap will return map of collectionID to PublicURLs which are not disabled yet.-// Note: The url could be expired or deviceLimit is already reached+// "Active" only means not disabled; links may be expired or over their limit.func (pcr *CollectionLinkRepo) GetCollectionToActivePublicURLMap(ctx context.Context, collectionIDs []int64, app ente.App) (map[int64][]ente.PublicURL, error) {rows, err := pcr.DB.QueryContext(ctx, `SELECT collection_id, access_token, valid_till, device_limit, enable_download, enable_collect, enable_comment, enable_join, min_role, pw_nonce, mem_limit, ops_limit FROMpublic_collection_tokens WHERE collection_id = ANY($1) and is_disabled = FALSE`,@@ -121,8 +119,7 @@ func (pcr *CollectionLinkRepo) GetCollectionToActivePublicURLMap(ctx context.Conreturn result, nil}-// GetActiveCollectionLinkRow will return ente.CollectionLinkRow for given collection ID-// Note: The token could be expired or deviceLimit is already reached+// "Active" only means not disabled; the link may be expired or over its limit.func (pcr *CollectionLinkRepo) GetActiveCollectionLinkRow(ctx context.Context, collectionID int64) (ente.CollectionLinkRow, error) {row := pcr.DB.QueryRowContext(ctx, `SELECT id, collection_id, access_token, valid_till, device_limit,is_disabled, pw_hash, pw_nonce, mem_limit, ops_limit, enable_download, enable_collect, enable_comment, enable_join, min_role FROM@@ -156,8 +153,6 @@ func (pcr *CollectionLinkRepo) UpdatePublicCollectionToken(ctx context.Context,return stacktrace.Propagate(err, "failed to update public collection token")}-// Report-abuse functionality removed; DB left intact.-func (pcr *CollectionLinkRepo) GetUniqueAccessCount(ctx context.Context, shareId int64) (int64, error) {row := pcr.DB.QueryRowContext(ctx, `SELECT count(*) FROM public_collection_access_history WHERE share_id = $1`, shareId)var count int64 = 0@@ -176,7 +171,6 @@ func (pcr *CollectionLinkRepo) RecordAccessHistory(ctx context.Context, shareIDreturn stacktrace.Propagate(err, "failed to record access history")}-// AccessedInPast returns true if the given ip, ua agent combination has accessed the url in the pastfunc (pcr *CollectionLinkRepo) AccessedInPast(ctx context.Context, shareID int64, ip string, ua string) (bool, error) {row := pcr.DB.QueryRowContext(ctx, `select share_id from public_collection_access_history where share_id =$1 and ip = $2 and user_agent = $3`,shareID, ip, ua)diff --git a/server/pkg/repo/queue.go b/server/pkg/repo/queue.goindex 936ea0be5a..7e298a176a 100644--- a/server/pkg/repo/queue.go+++ b/server/pkg/repo/queue.go@@ -16,18 +16,17 @@ type QueueRepository struct {DB *sql.DB}-// itemDeletionDelayInMinMap tracks the delay (in min) after which an item is ready to be processed.-// -ve entry indicates that the item should be processed immediately, without any delay.+// Negative delays make items immediately eligible.var itemDeletionDelayInMinMap = map[string]int64{- DropFileEncMedataQueue: -1 * 24 * 60, // -ve value to ensure attributes are immediately removed- DeleteObjectQueue: 45 * 24 * 60, // 45 days in minutes- DeleteEmbeddingsQueue: -1 * 24 * 60, // -ve value to ensure embeddings are immediately removed- OutdatedObjectsQueue: -1 * 24 * 60, // -ve value to process replaced objects without delay+ DropFileEncMedataQueue: -1 * 24 * 60,+ DeleteObjectQueue: 45 * 24 * 60,+ DeleteEmbeddingsQueue: -1 * 24 * 60,+ OutdatedObjectsQueue: -1 * 24 * 60,DeleteOutdatedObjectQueue: 24 * 24 * 60, // old replaced objects may exist in compliance-protected replicas- TrashCollectionQueueV3: -1 * 24 * 60, // -ve value to ensure collections are immediately marked as trashed- TrashEmptyQueue: -1 * 24 * 60, // -ve value to ensure empty trash request are processed in next cron run- TrashEmptyLockerQueue: -1 * 24 * 60, // -ve value to ensure empty trash request for locker are processed in next cron run- RemoveComplianceHoldQueue: -1 * 24 * 60, // -ve value to ensure compliance hold is removed in next cron run+ TrashCollectionQueueV3: -1 * 24 * 60,+ TrashEmptyQueue: -1 * 24 * 60,+ TrashEmptyLockerQueue: -1 * 24 * 60,+ RemoveComplianceHoldQueue: -1 * 24 * 60,}const (diff --git a/server/pkg/repo/tasklock.go b/server/pkg/repo/tasklock.goindex 521b86aad5..a7cb00f8bb 100644--- a/server/pkg/repo/tasklock.go+++ b/server/pkg/repo/tasklock.go@@ -29,10 +29,6 @@ func (repo *TaskLockRepository) AcquireLock(name string, lockUntil int64, lockedreturn rowsAffected == 1, nil}-// ExtendLock updates the locked_at and locked_until of an existing lock (held-// by `lockedBy`).-//-// Returns false if there is no such existing lock.func (repo *TaskLockRepository) ExtendLock(name string, lockUntil int64, lockedBy string) (bool, error) {result, err := repo.DB.Exec(`UPDATE task_lock SET locked_at = $1, lock_until = $2@@ -50,10 +46,8 @@ func (repo *TaskLockRepository) ExtendLock(name string, lockUntil int64, lockedBreturn rowsAffected == 1, nil}-// LastLockedAt returns the time (epoch microseconds) at which the lock with-// `name` was last acquired or refreshed.-//-// If there is no such lock, it'll return sql.ErrNoRows.+// The timestamp is in epoch microseconds.+// Missing locks return sql.ErrNoRows.func (repo *TaskLockRepository) LastLockedAt(name string) (int64, error) {row := repo.DB.QueryRow(`SELECT locked_at FROM task_lock WHERE task_name = $1`, name)