π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix minor bugs
Neeraj Guptab64a69ebf0f7
diff --git a/server/migrations/102_single_file_url.up.sql b/server/migrations/102_single_file_url.up.sqlindex 0f94897ba2..3145e46aad 100644--- a/server/migrations/102_single_file_url.up.sql+++ b/server/migrations/102_single_file_url.up.sql@@ -43,4 +43,4 @@ CREATE TABLE IF NOT EXISTS public_file_tokens_access_historyCREATE UNIQUE INDEX IF NOT EXISTS public_file_token_unique_idx ON public_file_tokens (access_token) WHERE is_disabled = FALSE;CREATE INDEX IF NOT EXISTS public_file_tokens_owner_id_updated_at_idx ON public_file_tokens (owner_id, updated_at);-+CREATE UNIQUE INDEX IF NOT EXISTS public_active_file_link_unique_idx ON public_file_tokens (file_id, is_disabled) WHERE is_disabled = FALSE;diff --git a/server/pkg/repo/public/file_link.go b/server/pkg/repo/public/file_link.goindex b737ddfdf3..9affce0f57 100644--- a/server/pkg/repo/public/file_link.go+++ b/server/pkg/repo/public/file_link.go@@ -31,8 +31,9 @@ func NewFileLinkRepo(db *sql.DB) *FileLinkRepository {lockerHost = "https://locker.ente.io"}return &FileLinkRepository{- DB: db,- photoHost: albumHost,+ DB: db,+ photoHost: albumHost,+ lockerHost: lockerHost,}}@@ -59,7 +60,7 @@ func (pcr *FileLinkRepository) Insert((id, file_id, owner_id, access_token, app) VALUES ($1, $2, $3, $4, $5)`,id, fileID, ownerID, token, string(app))if err != nil {- if err.Error() == "pq: duplicate key value violates unique constraint \"public_file_token_unique_idx\"" {+ if err.Error() == "pq: duplicate key value violates unique constraint \"public_active_file_link_unique_idx\"" {return nil, ente.ErrActiveLinkAlreadyExists}return nil, stacktrace.Propagate(err, "failed to insert")@@ -152,12 +153,12 @@ func (pcr *FileLinkRepository) GetFileUrlRowByToken(ctx context.Context, accessTfunc (pcr *FileLinkRepository) GetFileUrlRowByFileID(ctx context.Context, fileID int64) (*ente.FileLinkRow, error) {row := pcr.DB.QueryRowContext(ctx,- `SELECT id, file_id, owner_id, is_disabled, enable_download, valid_till, device_limit, pw_hash, pw_nonce, mem_limit, ops_limit,+ `SELECT id, file_id, access_token, owner_id, is_disabled, enable_download, valid_till, device_limit, pw_hash, pw_nonce, mem_limit, ops_limit,created_at, updated_atfrom public_file_tokenswhere file_id = $1 and is_disabled = FALSE`, fileID)var result = ente.FileLinkRow{}- err := row.Scan(&result.LinkID, &result.FileID, &result.OwnerID, &result.IsDisabled, &result.EnableDownload, &result.ValidTill, &result.DeviceLimit, &result.PassHash, &result.Nonce, &result.MemLimit, &result.OpsLimit, &result.CreatedAt, &result.UpdatedAt)+ err := row.Scan(&result.LinkID, &result.FileID, &result.Token, &result.OwnerID, &result.IsDisabled, &result.EnableDownload, &result.ValidTill, &result.DeviceLimit, &result.PassHash, &result.Nonce, &result.MemLimit, &result.OpsLimit, &result.CreatedAt, &result.UpdatedAt)if err != nil {if err == sql.ErrNoRows {return nil, ente.ErrNotFound