Skip to content

Commit

Permalink
[server][file-data] Fix query to mark replication as done
Browse files Browse the repository at this point in the history
  • Loading branch information
ua741 committed Aug 12, 2024
1 parent 6fc24f6 commit cfadd70
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/pkg/repo/filedata/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ func (r *Repository) GetPendingSyncDataAndExtendLock(ctx context.Context, newSyn
return &fileData, nil
}

// MarkReplicationAsDone marks the pending_sync as false for the file data row
// MarkReplicationAsDone marks the pending_sync as false for the file data row, while
// ensuring that the row is not deleted
func (r *Repository) MarkReplicationAsDone(ctx context.Context, row filedata.Row) error {
query := `UPDATE file_data SET pending_sync = false WHERE is_deleted=true and file_id = $1 AND data_type = $2 AND user_id = $3`
query := `UPDATE file_data SET pending_sync = false WHERE is_deleted=false and file_id = $1 AND data_type = $2 AND user_id = $3`
_, err := r.DB.ExecContext(ctx, query, row.FileID, string(row.Type), row.UserID)
if err != nil {
return stacktrace.Propagate(err, "")
Expand Down

0 comments on commit cfadd70

Please sign in to comment.