Skip to content

armgit / ente

Public Imported from GitHub
0

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

Prune remaining server comments

Manav Rathiba654ea4eceb
diff --git a/rust/apps/cli/src/commands/export.rs b/rust/apps/cli/src/commands/export.rs
index a21df5b8c6..d7a8e8a678 100644
--- a/rust/apps/cli/src/commands/export.rs
+++ b/rust/apps/cli/src/commands/export.rs
@@ -1043,7 +1043,7 @@ async fn write_file_metadata(
let extension = Path::new(filename)
.extension()
.and_then(|s| s.to_str())
- .unwrap_or(""); // Extension might be legitimately missing for some files
+ .unwrap_or("");
let meta_filename = format!("{}_{}.{}.json", base_name, file_index, extension);
diff --git a/rust/apps/cli/src/commands/sync.rs b/rust/apps/cli/src/commands/sync.rs
index d7c534e1aa..affd72bd9f 100644
--- a/rust/apps/cli/src/commands/sync.rs
+++ b/rust/apps/cli/src/commands/sync.rs
@@ -391,11 +391,11 @@ async fn prepare_download_tasks(
sanitize_filename(title)
} else {
log::error!("File {} has no title in metadata", file.id);
- continue; // Skip this file
+ continue;
}
} else {
log::error!("File {} has no metadata", file.id);
- continue; // Skip this file
+ continue;
};
if let Some(ref meta) = metadata {
diff --git a/rust/apps/cli/src/storage/account.rs b/rust/apps/cli/src/storage/account.rs
index 76671a469f..336d173e88 100644
--- a/rust/apps/cli/src/storage/account.rs
+++ b/rust/apps/cli/src/storage/account.rs
@@ -145,7 +145,7 @@ fn row_to_account(row: &Row) -> rusqlite::Result<Account> {
"photos" => App::Photos,
"locker" => App::Locker,
"auth" => App::Auth,
- _ => App::Photos, // Default fallback
+ _ => App::Photos,
};
Ok(Account {
diff --git a/server/cmd/museum/main.go b/server/cmd/museum/main.go
index b426618f63..df8902390e 100644
--- a/server/cmd/museum/main.go
+++ b/server/cmd/museum/main.go
@@ -154,8 +154,7 @@ func main() {
TaskLockingRepo: taskLockingRepo,
HostName: hostName,
}
- // Note: during boot-up, release any locks that might have been left behind.
- // This is a safety measure to ensure that no locks are left behind in case of a crash or restart.
+ // Clear locks left by a crash or restart.
lockController.ReleaseHostLock()
var latencyLogger = promauto.NewHistogramVec(prometheus.HistogramOpts{
@@ -877,7 +876,7 @@ func main() {
publicAPI.GET("/family/invite-info/:token", familyHandler.GetInviteInfo)
publicAPI.POST("/family/accept-invite", familyHandler.AcceptInvite)
- privateAPI.DELETE("/family/leave", familyHandler.Leave) // native/web app
+ privateAPI.DELETE("/family/leave", familyHandler.Leave)
familyAuthAPI.POST("/family/create", familyHandler.CreateFamily)
familyAuthAPI.POST("/family/add-member", familyHandler.InviteMember)
@@ -1264,7 +1263,7 @@ func setupAndStartBackgroundJobs(
return
}
- fileDataCtrl.StartDataDeletion() // Start data deletion for file data;
+ fileDataCtrl.StartDataDeletion()
contactController.StartDataDeletion()
objectCleanupController.StartRemovingUnreportedObjects()
spaceModule.Cleanup.StartRemovingUnreportedObjects()
@@ -1434,7 +1433,6 @@ func cors() gin.HandlerFunc {
func cacheHeaders() gin.HandlerFunc {
return func(c *gin.Context) {
- // Add "Cache-Control: no-store" to HTTP GET API responses.
if c.Request.Method == http.MethodGet {
reqPath := urlSanitizer(c)
if reqPath == "/files/preview/:fileID" ||
diff --git a/server/ente/admin.go b/server/ente/admin.go
index e50cc3fe4c..13d106bbf5 100644
--- a/server/ente/admin.go
+++ b/server/ente/admin.go
@@ -10,10 +10,6 @@ type GetEmailsFromHashesRequest struct {
Hashes []string `json:"hashes"`
}
-// Admin API request to disable 2FA for a user account.
-//
-// This is used when we get a user request to reset their 2FA when they might've
-// lost access to their 2FA codes. We verify their identity out of band.
type DisableTwoFactorRequest struct {
UserID int64 `json:"userID" binding:"required"`
}
diff --git a/server/ente/anonymous_identity.go b/server/ente/anonymous_identity.go
index a1212bc7f4..64246ddc5c 100644
--- a/server/ente/anonymous_identity.go
+++ b/server/ente/anonymous_identity.go
@@ -16,7 +16,7 @@ type AnonymousIdentityClaim struct {
func NewAnonymousIdentityToken(secret []byte, anonUserID string) (string, int64, error) {
issuedAt := time.Now()
- expiry := issuedAt.AddDate(1, 0, 0) // 1 year validity
+ expiry := issuedAt.AddDate(1, 0, 0)
claim := AnonymousIdentityClaim{
Typ: anonIdentityTokenType,
RegisteredClaims: jwt.RegisteredClaims{
diff --git a/server/ente/family.go b/server/ente/family.go
index e64af5b143..6b76ef2718 100644
--- a/server/ente/family.go
+++ b/server/ente/family.go
@@ -65,7 +65,7 @@ type FamilyMemberResponse struct {
}
type UserUsageWithSubData struct {
- UserID int64
+ UserID int64
StorageConsumed int64
ExpiryTime int64
Storage int64
diff --git a/server/ente/file_link.go b/server/ente/file_link.go
index 5f990b3458..a244bba81a 100644
--- a/server/ente/file_link.go
+++ b/server/ente/file_link.go
@@ -80,15 +80,14 @@ type FileLinkRow struct {
}
type FileUrl struct {
- LinkID string `json:"linkID" binding:"required"`
- URL string `json:"url" binding:"required"`
- OwnerID int64 `json:"ownerID" binding:"required"`
- FileID int64 `json:"fileID" binding:"required"`
- IsDisabled bool `json:"isDisabled"`
- ValidTill int64 `json:"validTill"`
- DeviceLimit int `json:"deviceLimit"`
- PasswordEnabled bool `json:"passwordEnabled"`
- // Nonce contains the nonce value for the password if the link is password protected.
+ LinkID string `json:"linkID" binding:"required"`
+ URL string `json:"url" binding:"required"`
+ OwnerID int64 `json:"ownerID" binding:"required"`
+ FileID int64 `json:"fileID" binding:"required"`
+ IsDisabled bool `json:"isDisabled"`
+ ValidTill int64 `json:"validTill"`
+ DeviceLimit int `json:"deviceLimit"`
+ PasswordEnabled bool `json:"passwordEnabled"`
Nonce *string `json:"nonce,omitempty"`
MemLimit *int64 `json:"memLimit,omitempty"`
OpsLimit *int64 `json:"opsLimit,omitempty"`
diff --git a/server/ente/filedata/filedata.go b/server/ente/filedata/filedata.go
index 8ee26ceaec..c67ef15561 100644
--- a/server/ente/filedata/filedata.go
+++ b/server/ente/filedata/filedata.go
@@ -128,8 +128,8 @@ type Row struct {
Size int64
LatestBucket string
ObjectID *string
- // For HLS video object, there's no object nonce, all relevant data
- // is stored in the metadata object that primarily contains the playlist.
+ // HLS video uses the default nonce with a one-time key stored in the playlist
+ // metadata, so no object nonce is stored.
ObjectNonce *string
// Size of the object that is stored in the S3 bucket.
// In case of HLS video, this points to the size of the encrypted video.
diff --git a/server/ente/legacy_kit.go b/server/ente/legacy_kit.go
index 8429d05cc5..5b15842304 100644
--- a/server/ente/legacy_kit.go
+++ b/server/ente/legacy_kit.go
@@ -90,9 +90,9 @@ type LegacyKitRecoveryInitiator struct {
// Share indexes reported by the recovery client as the shares used to
// reconstruct the kit secret. This is an audit hint, not an authorization
// primitive.
- UsedPartIndexes []int `json:"usedPartIndexes,omitempty"`
- IP string `json:"ip"`
- UserAgent string `json:"userAgent"`
+ UsedPartIndexes []int `json:"usedPartIndexes,omitempty"`
+ IP string `json:"ip"`
+ UserAgent string `json:"userAgent"`
}
type LegacyKitOwnerRecoverySessionResponse struct {
diff --git a/server/ente/passkeyCredential.go b/server/ente/passkeyCredential.go
index 1973a13556..9e12301434 100644
--- a/server/ente/passkeyCredential.go
+++ b/server/ente/passkeyCredential.go
@@ -10,13 +10,10 @@ import (
"github.com/google/uuid"
)
-// PasskeyCredential is our stored representation of a WebAuthn credential.
-// The credential material is converted back into webauthn.Credential during
-// authentication; RPID records which relying party the credential is scoped to.
type PasskeyCredential struct {
PasskeyID uuid.UUID `json:"passkeyID"`
- CredentialID string `json:"credentialID"` // string
+ CredentialID string `json:"credentialID"`
RPID string `json:"rpID"`
PublicKey string `json:"publicKey"` // b64 []byte
diff --git a/server/ente/public_collection.go b/server/ente/public_collection.go
index 000bb6ce85..e3b9b7589c 100644
--- a/server/ente/public_collection.go
+++ b/server/ente/public_collection.go
@@ -108,19 +108,18 @@ func (p CollectionLinkRow) CanJoin() error {
}
type PublicURL struct {
- URL string `json:"url"`
- DeviceLimit int `json:"deviceLimit"`
- ValidTill int64 `json:"validTill"`
- EnableDownload bool `json:"enableDownload"`
- EnableCollect bool `json:"enableCollect"`
- EnableComment bool `json:"enableComment"`
- PasswordEnabled bool `json:"passwordEnabled"`
- // Nonce contains the nonce value for the password if the link is password protected.
- Nonce *string `json:"nonce,omitempty"`
- MemLimit *int64 `json:"memLimit,omitempty"`
- OpsLimit *int64 `json:"opsLimit,omitempty"`
- EnableJoin bool `json:"enableJoin"`
- MinRole *CollectionParticipantRole `json:"minRole,omitempty"`
+ URL string `json:"url"`
+ DeviceLimit int `json:"deviceLimit"`
+ ValidTill int64 `json:"validTill"`
+ EnableDownload bool `json:"enableDownload"`
+ EnableCollect bool `json:"enableCollect"`
+ EnableComment bool `json:"enableComment"`
+ PasswordEnabled bool `json:"passwordEnabled"`
+ Nonce *string `json:"nonce,omitempty"`
+ MemLimit *int64 `json:"memLimit,omitempty"`
+ OpsLimit *int64 `json:"opsLimit,omitempty"`
+ EnableJoin bool `json:"enableJoin"`
+ MinRole *CollectionParticipantRole `json:"minRole,omitempty"`
}
type PublicAccessContext struct {
@@ -153,9 +152,8 @@ type PublicCollectionSummary struct {
CreatedAt int64
UpdatedAt int64
DeviceAccessCount int
- // not empty value of passHash indicates that the link is password protected.
- PassHash *string
- EnableComment bool
+ PassHash *string
+ EnableComment bool
}
type AbuseReportRequest struct {
diff --git a/server/ente/remotestore.go b/server/ente/remotestore.go
index a8a3ee6c43..aa554d9437 100644
--- a/server/ente/remotestore.go
+++ b/server/ente/remotestore.go
@@ -153,14 +153,10 @@ func ValidatePublicCustomDomain(value string) error {
const customDomainFamilyPrefix = "_"
-// BuildFamilyCustomDomainPointer builds a member-scoped custom domain pointer
-// to keep the custom domain unique across family members.
func BuildFamilyCustomDomainPointer(memberID int64, domain string) string {
return fmt.Sprintf("%s%d:%s", customDomainFamilyPrefix, memberID, domain)
}
-// ParseFamilyCustomDomainPointer parses a custom domain pointer of the form _<userID>:<domain>.
-// Returns (userID, domain, isPointer, error).
func ParseFamilyCustomDomainPointer(value string) (int64, string, bool, error) {
if !strings.HasPrefix(value, customDomainFamilyPrefix) {
return 0, "", false, nil
diff --git a/server/ente/storagebonus/storge_bonus.go b/server/ente/storagebonus/storge_bonus.go
index 8e866d9d5c..655b4d80f7 100644
--- a/server/ente/storagebonus/storge_bonus.go
+++ b/server/ente/storagebonus/storge_bonus.go
@@ -72,7 +72,7 @@ type StorageBonus struct {
Type BonusType `json:"type"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"-"`
- // ValidTill represents the validity of the storage bonus. If it is 0, it is valid forever.
+ // Zero means no expiry.
ValidTill int64 `json:"validTill"`
RevokeReason *RevokeReason `json:"-"`
IsRevoked bool `json:"isRevoked"`
diff --git a/server/pkg/api/admin.go b/server/pkg/api/admin.go
index ad83d591db..3e58d774cc 100644
--- a/server/pkg/api/admin.go
+++ b/server/pkg/api/admin.go
@@ -221,6 +221,8 @@ func (h *AdminHandler) isFreshAdminToken(c *gin.Context) error {
return nil
}
+// Used when a user who has lost access to their 2FA codes asks to reset 2FA.
+// Their identity is verified out of band.
func (h *AdminHandler) DisableTwoFactor(c *gin.Context) {
err := h.isFreshAdminToken(c)
if err != nil {
@@ -269,9 +271,9 @@ func (h *AdminHandler) UpdateReferral(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
}
-// RemovePasskeys is an admin API request to disable passkey 2FA for a user account by removing its passkeys.
-// This is used when we get a user request to reset their passkeys 2FA when they might've lost access to their devices or synced stores. We verify their identity out of band.
-// BY DEFAULT, IF THE USER HAS TOTP BASED 2FA ENABLED, REMOVING PASSKEYS WILL NOT DISABLE TOTP 2FA.
+// Used when a user who has lost access to their devices or synced stores asks
+// to reset passkey 2FA. Their identity is verified out of band. Removing
+// passkeys does not disable TOTP 2FA.
func (h *AdminHandler) RemovePasskeys(c *gin.Context) {
var request ente.AdminOpsForUserRequest
if err := handler.BindJSON(c, &request); err != nil {
diff --git a/server/pkg/api/billing.go b/server/pkg/api/billing.go
index 9dc9d4d1f6..4f3f38d7a4 100644
--- a/server/pkg/api/billing.go
+++ b/server/pkg/api/billing.go
@@ -174,7 +174,6 @@ func (h *BillingHandler) GetCheckoutSession(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"sessionID": sessionID})
}
-// StripeINNotificationHandler handles the notifications from older StripeIN account
func (h *BillingHandler) StripeINNotificationHandler(c *gin.Context) {
notification, err := io.ReadAll(c.Request.Body)
if err != nil {
@@ -191,7 +190,6 @@ func (h *BillingHandler) StripeINNotificationHandler(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{})
}
-// StripeUSNotificationHandler handles the notifications from new StripeUS account
func (h *BillingHandler) StripeUSNotificationHandler(c *gin.Context) {
notification, err := io.ReadAll(c.Request.Body)
if err != nil {
diff --git a/server/pkg/controller/access/file.go b/server/pkg/controller/access/file.go
index 9d6e80371c..0a0753929f 100644
--- a/server/pkg/controller/access/file.go
+++ b/server/pkg/controller/access/file.go
@@ -39,14 +39,12 @@ func (c controllerImpl) CanAccessFile(ctx *gin.Context, req *CanAccessFileParams
return stacktrace.Propagate(err, "failed to get owner to fileIDs map")
}
- // Only fetch shared collections once when needed
var sharedCollections []int64
for owner, fileIDs := range ownerToFilesMap {
if owner == req.ActorUserID {
continue
}
- // Lazy load collections only when we need to check permissions
if sharedCollections == nil {
sharedCollections, err = c.CollectionRepo.GetCollectionsSharedWithOrByUser(req.ActorUserID)
if err != nil {
diff --git a/server/pkg/controller/collections/cast.go b/server/pkg/controller/collections/cast.go
index 35f3b2a984..e8e899a5fa 100644
--- a/server/pkg/controller/collections/cast.go
+++ b/server/pkg/controller/collections/cast.go
@@ -33,7 +33,7 @@ func (c *CollectionController) GetCastDiff(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 cast diff.
for idx := range diff {
if diff[idx].MagicMetadata != nil {
diff[idx].MagicMetadata = nil
@@ -47,7 +47,7 @@ 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
+ // "-" 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/data_cleanup/controller.go b/server/pkg/controller/data_cleanup/controller.go
index 828bcb923e..3861079270 100644
--- a/server/pkg/controller/data_cleanup/controller.go
+++ b/server/pkg/controller/data_cleanup/controller.go
@@ -193,7 +193,6 @@ func (c *DeleteUserCleanupController) storageCheck(ctx context.Context, item *en
return stacktrace.Propagate(err, "")
}
} else if item.StageAttemptCount >= maxStorageCheckAttempt {
- // Note: if storage is still not zero after maxStorageCheckAttempt attempts and trash is empty, mark the clean-up as done
return c.completeCleanup(ctx, item)
}
return fmt.Errorf("storage consumed is not zero: %d", usage)
diff --git a/server/pkg/controller/playstore.go b/server/pkg/controller/playstore.go
index 285abe311d..c9d5023685 100644
--- a/server/pkg/controller/playstore.go
+++ b/server/pkg/controller/playstore.go
@@ -101,7 +101,6 @@ func (c *PlayStoreController) HandleNotification(notification playstore.Develope
user, err := c.UserRepo.Get(subscription.UserID)
if err != nil {
if errors.Is(err, ente.ErrUserDeleted) {
- // no-op user has already been deleted
return nil
}
return stacktrace.Propagate(err, "")
diff --git a/server/pkg/controller/remotestore/controller.go b/server/pkg/controller/remotestore/controller.go
index 6c72356ca3..eac97b815b 100644
--- a/server/pkg/controller/remotestore/controller.go
+++ b/server/pkg/controller/remotestore/controller.go
@@ -103,9 +103,7 @@ func (c *Controller) GetFeatureFlags(ctx *gin.Context) (*ente.FeatureFlagRespons
response := &ente.FeatureFlagResponse{
EnableStripe: true,
DisableCFWorker: false,
- // When true, users will see an option to enable multiple part upload in the app
- // Changing it to false will hide the option and disable multi part upload for everyone
- // except internal user.rt
+ // Disabling this still leaves multipart enabled for internal users.
EnableMobMultiPart: true,
ServerApiFlag: ente.UploadV2 | ente.Comments | ente.BackupOptions | ente.CastSessionsV2 | ente.DeferredMultipartChecksums,
CastUrl: viper.GetString("apps.cast"),
diff --git a/server/pkg/controller/replication3.go b/server/pkg/controller/replication3.go
index bd724dde72..eb92e2b931 100644
--- a/server/pkg/controller/replication3.go
+++ b/server/pkg/controller/replication3.go
@@ -48,11 +48,11 @@ type ReplicationController3 struct {
}
type UploadDestination struct {
- DC string
- Client *s3.S3
- Uploader *s3manager.Uploader
- Bucket *string
- Label string
+ DC string
+ Client *s3.S3
+ Uploader *s3manager.Uploader
+ Bucket *string
+ Label string
HasComplianceHold bool
IsGlacier bool
}
@@ -172,7 +172,6 @@ func (c *ReplicationController3) replicate(i int) {
for {
err := c.tryReplicate()
if err != nil {
- // Stagger retries across workers.
time.Sleep(time.Duration(i+1) * time.Minute)
}
}
diff --git a/server/pkg/controller/user/inactive_user_orchestrator.go b/server/pkg/controller/user/inactive_user_orchestrator.go
index 5de608a918..1c2a21d95c 100644
--- a/server/pkg/controller/user/inactive_user_orchestrator.go
+++ b/server/pkg/controller/user/inactive_user_orchestrator.go
@@ -361,7 +361,6 @@ func (c *InactiveUserOrchestrator) processCandidate(candidate repo.UserInactivit
return stageHint, false, false, err
}
if !found {
- // User is no longer active.
return inactivityEmailStageNone, false, false, nil
}
diff --git a/server/pkg/controller/user/srp.go b/server/pkg/controller/user/srp.go
index 46cc3563f8..1c42e5ea07 100644
--- a/server/pkg/controller/user/srp.go
+++ b/server/pkg/controller/user/srp.go
@@ -21,7 +21,7 @@ import (
)
const (
- Srp4096Params = 4096
+ Srp4096Params = 4096
MaxUnverifiedSessionInAnHour = 10
// Used for nonexistent users to preserve SRP timing and prevent enumeration.
FakeVerifier = "RNYLOgdzKsbhRWN8OoD05kNpfbqb9uASHYpaLrYLYVemCV0pf4fBgo+25jeu8SaVMQhlkyIF2BgGXX4uzy8Pmwq1ocqt8DsGk0DrlOE1AV9ogaY3myoTjXTQG5dU/hTywylKJYdpWSEyzMMLbWcuO8ldS6uzYXqK+jbfEDDj8k4PqLx1715BPgigNydCbD7/VtwaMhQ8MEygiW/2PbieeqUzuCqEWfwu0uytPM9LiuHH7DT3k2fELFOoPWs3KQAhk6rmM17JOLm8Qvt+xGU6nJZKzTNPxw9o4H4FvlGmsEYUdTP+WPdWpzcton6BowCXKN9G3hZx10OUzBuePHFNKjDlaSLpJXVclLWmza6aDBpjKahayW2UvdQw1tSonyFUjJOanocrPEoHthHUjUGXkeRqcaU4CV9KLQFaHqnHTYc9uJKuYl/tcYoWXuHrZ0cFYRpc6qf/gBCuuwkhTXXsJxTlepe5x0gqgQb7mD5y+dvINks/gpO/3x4T4RkQcyoonsOZv2uLIBr3D6Ede9/aJstIkMh3dTEpDWdw8tEaO7ZjqEwKXVA+/fquJ7P8B3fcIvPy8UZOpwAYtWSPh3OYzijG7WFXu+ajPBqkVI1OBSCYOlTQlPXyrv7myiD8/FXJep5IDPeuJsmGrLPJXBZjPKWR0ISBWol5KTYWE2EllYQ="
diff --git a/server/pkg/controller/user/user_delete.go b/server/pkg/controller/user/user_delete.go
index 498c6ba27c..b08d88a6f5 100644
--- a/server/pkg/controller/user/user_delete.go
+++ b/server/pkg/controller/user/user_delete.go
@@ -88,7 +88,6 @@ func (c *UserController) SelfDeleteAccount(ctx *gin.Context, req ente.DeleteAcco
if err != nil {
return nil, stacktrace.Propagate(err, "")
}
- // Update reason, ignore failure in updating reason
updateErr := c.UserRepo.UpdateDeleteFeedback(userID, req.GetReasonAttr())
if updateErr != nil {
logger.WithError(updateErr).Error("failed to update delete feedback")
diff --git a/server/pkg/middleware/rate_limit.go b/server/pkg/middleware/rate_limit.go
index 76b166b37b..0856696ce9 100644
--- a/server/pkg/middleware/rate_limit.go
+++ b/server/pkg/middleware/rate_limit.go
@@ -113,7 +113,6 @@ func (r *RateLimitMiddleware) APIRateLimitForUserMiddleware(urlSanitizer func(_
if rateLimiter != nil {
userID := auth.GetUserID(c.Request.Header)
if userID == 0 {
- // do not apply limit, just log
log.Error("userID must be present in request header for applying rate-limit")
return
}
diff --git a/server/pkg/middleware/request_logger.go b/server/pkg/middleware/request_logger.go
index 09dbeccc95..f651d8b878 100644
--- a/server/pkg/middleware/request_logger.go
+++ b/server/pkg/middleware/request_logger.go
@@ -30,8 +30,7 @@ var latency = promauto.NewHistogramVec(prometheus.HistogramOpts{
Buckets: []float64{10, 50, 100, 200, 500, 1000, 10000, 30000, 60000, 120000, 600000},
}, []string{"code", "method", "host", "url"})
-// shouldSkipBodyLog returns true if the body should not be logged.
-// This is useful for endpoints that receive large or sensitive payloads.
+// Skip read-only requests and writes with large or sensitive bodies.
func shouldSkipBodyLog(method string, path string) bool {
isReadOnly := method == http.MethodGet || method == http.MethodHead || method == http.MethodOptions
if !isReadOnly {
diff --git a/server/pkg/repo/object.go b/server/pkg/repo/object.go
index 49faa9cd9d..3c61dd92b4 100644
--- a/server/pkg/repo/object.go
+++ b/server/pkg/repo/object.go
@@ -92,6 +92,7 @@ func (repo *ObjectRepository) GetAccessibleObject(ctx context.Context, fileID in
return s3ObjectKey, err
}
+// Keep access validation and object lookup in one latency-sensitive query.
func (repo *ObjectRepository) GetAccessibleObjectWithDCs(ctx context.Context, fileID int64, actorUserID int64, objType ente.ObjectType) (ente.S3ObjectKey, []string, error) {
row := repo.objectLookupDB().QueryRowContext(ctx, `
SELECT
@@ -154,6 +155,7 @@ func (repo *ObjectRepository) GetOwnedObject(ctx context.Context, fileID int64,
return s3ObjectKey, err
}
+// Keep ownership validation and object lookup in one latency-sensitive query.
func (repo *ObjectRepository) GetOwnedObjectWithDCs(ctx context.Context, fileID int64, ownerID int64, objType ente.ObjectType) (ente.S3ObjectKey, []string, error) {
row := repo.objectLookupDB().QueryRowContext(ctx, `
SELECT
@@ -205,6 +207,8 @@ func (repo *ObjectRepository) GetCollectionObject(ctx context.Context, collectio
return s3ObjectKey, err
}
+// Keep collection access validation and object lookup in one latency-sensitive
+// query.
func (repo *ObjectRepository) GetCollectionObjectWithDCs(ctx context.Context, collectionID int64, fileID int64, objType ente.ObjectType) (ente.S3ObjectKey, []string, error) {
row := repo.objectLookupDB().QueryRowContext(ctx, `
SELECT
diff --git a/server/pkg/repo/storagebonus/referral_codes.go b/server/pkg/repo/storagebonus/referral_codes.go
index 0874ba373f..eea44bf9d8 100644
--- a/server/pkg/repo/storagebonus/referral_codes.go
+++ b/server/pkg/repo/storagebonus/referral_codes.go
@@ -60,8 +60,6 @@ func (r *Repository) AddNewCode(ctx context.Context, userID int64, code string,
return r.InsertCode(ctx, userID, code)
}
-// GetCodeChangeCount returns the number of times the user has changed their referral code.
-// A count of 1 means no changes (only the initial code exists).
func (r *Repository) GetCodeChangeCount(ctx context.Context, userID int64) (int, error) {
var count int
err := r.DB.QueryRowContext(ctx, "SELECT COALESCE(COUNT(*),0) FROM referral_codes WHERE user_id = $1", userID).Scan(&count)
@@ -71,8 +69,7 @@ func (r *Repository) GetCodeChangeCount(ctx context.Context, userID int64) (int,
return count, nil
}
-// GetUserIDByCode returns the userID for the given storagebonus code. The method will also return the userID
-// if the code is inactive.
+// Inactive codes still resolve to their owner.
func (r *Repository) GetUserIDByCode(ctx context.Context, code string) (*int64, error) {
var userID int64
err := r.DB.QueryRowContext(ctx, "SELECT user_id FROM referral_codes WHERE code = $1", code).Scan(&userID)
diff --git a/server/pkg/utils/email/email.go b/server/pkg/utils/email/email.go
index 5dd47cbdce..1953444525 100644
--- a/server/pkg/utils/email/email.go
+++ b/server/pkg/utils/email/email.go
@@ -56,7 +56,6 @@ func containsCRLF(s string) bool {
return strings.ContainsRune(s, '\r') || strings.ContainsRune(s, '\n')
}
-// wrapToMaxLineLength inserts LF breaks into long base64 blobs to respect SMTP limits.
func wrapToMaxLineLength(s string, maxLen int) string {
if maxLen <= 0 {
return s
diff --git a/server/pkg/utils/s3config/s3config.go b/server/pkg/utils/s3config/s3config.go
index a19ac6bbb1..6b00241465 100644
--- a/server/pkg/utils/s3config/s3config.go
+++ b/server/pkg/utils/s3config/s3config.go
@@ -27,7 +27,7 @@ type S3Config struct {
// debugging workarounds; not tested/intended for production.
areLocalBuckets bool
- fileDataConfig FileDataConfig
+ fileDataConfig FileDataConfig
attachmentConfig AttachmentConfig
}