[server][file-data] Fix query to mark replication as done

This commit is contained in:
Neeraj Gupta
2024-08-12 21:56:46 +05:30
committed by Neeraj Gupta
parent 6fc24f6900
commit cfadd700ff

View File

@@ -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, "")