Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/server/routes/domain-updater/updateFns/ssl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ export async function updateSSL(
newVal = normalizeStr(newVal);
}


// Skip if both values are empty (no real change)
if (!oldVal && !newVal) {
continue;
}

// Special date comparison, because timezones are stupid
if (field.type === 'date') {
const oldDate = new Date(oldVal);
Expand All @@ -83,6 +87,12 @@ export async function updateSSL(
const diffInMs = Math.abs(newDate.getTime() - oldDate.getTime());
const diffInDays = diffInMs / (1000 * 60 * 60 * 24);

// Skip if new value is invalid/empty (NaN means we couldn't parse the new date)
// This prevents ghost changes when SSL fetch fails
if (isNaN(diffInDays) && !newVal) {
continue;
}

if (isNaN(diffInDays) || diffInDays > 1) {
updateSet.push(`${field.column} = $${updateSet.length + 2}::date`);
updateValues.push(toDateOnly(newVal));
Expand All @@ -92,6 +102,11 @@ export async function updateSSL(
}

if (oldVal !== newVal && field.type != 'date') {
// Skip recording if new value is empty (likely a fetch failure, not a real change)
if (!newVal && oldVal) {
continue;
}

updateSet.push(`${field.column} = $${updateSet.length + 2}::${field.type}`);
updateValues.push(field.new ?? null);

Expand Down