From 24a8def394252a59db07e28978e39093ee713255 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sat, 15 Mar 2025 11:44:56 +0000 Subject: [PATCH] . --- frontend/sync-client/src/persistence/database.ts | 5 +++++ frontend/sync-client/src/services/connected-state.ts | 1 - frontend/sync-client/src/utils/hash.ts | 2 +- frontend/test-client/src/cli.ts | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/sync-client/src/persistence/database.ts b/frontend/sync-client/src/persistence/database.ts index 0987c0de..2bcd77bc 100644 --- a/frontend/sync-client/src/persistence/database.ts +++ b/frontend/sync-client/src/persistence/database.ts @@ -301,6 +301,11 @@ export class Database { ); let newDocument = this.getLatestDocumentByRelativePath(newRelativePath); + if (newDocument !== undefined && !newDocument.isDeleted) { + throw new Error( + `Document already exists at new location: ${newRelativePath}` + ); + } // It's either an invalid state of newDocument is pending deletion and we have // to wait for it to complete. diff --git a/frontend/sync-client/src/services/connected-state.ts b/frontend/sync-client/src/services/connected-state.ts index da522816..e21ad005 100644 --- a/frontend/sync-client/src/services/connected-state.ts +++ b/frontend/sync-client/src/services/connected-state.ts @@ -1,4 +1,3 @@ -import { Syncer } from "../sync-operations/syncer"; import { Settings } from "../persistence/settings"; import { Logger } from "../tracing/logger"; import { createPromise } from "../utils/create-promise"; diff --git a/frontend/sync-client/src/utils/hash.ts b/frontend/sync-client/src/utils/hash.ts index 10f20d1d..cd965db5 100644 --- a/frontend/sync-client/src/utils/hash.ts +++ b/frontend/sync-client/src/utils/hash.ts @@ -6,7 +6,7 @@ export function hash(content: Uint8Array): string { result = (result << 5) - result + content[i]; result |= 0; // Convert to 32bit integer } - return Math.abs(result).toString(16); + return Math.abs(result).toString(16).padStart(8, "0"); } export const EMPTY_HASH = hash(new Uint8Array(0)); diff --git a/frontend/test-client/src/cli.ts b/frontend/test-client/src/cli.ts index e1a6fd5b..8e6e711b 100644 --- a/frontend/test-client/src/cli.ts +++ b/frontend/test-client/src/cli.ts @@ -92,7 +92,7 @@ async function runTest({ async function runTests(): Promise { const agentCounts = [2, 8]; const jitterScaleInSeconds = [0.5, 0, 2]; - const concurrencies = [16, 1]; + const concurrencies = [1]; const iterations = [50, 200]; const doDeletes = [true, false];