Remove force_merge flag

This commit is contained in:
Andras Schmelczer 2026-01-13 20:29:26 +00:00
parent bd8650e80b
commit ea5a123cb8
6 changed files with 33 additions and 50 deletions

View file

@ -68,27 +68,21 @@ export class SyncService {
public async create({
relativePath,
contentBytes,
forceMerge
}: {
relativePath: RelativePath;
contentBytes: Uint8Array;
forceMerge?: boolean;
}): Promise<DocumentUpdateResponse> {
return this.retryForever(async () => {
const formData = new FormData();
formData.append("relative_path", relativePath);
if (forceMerge === true) {
formData.append("force_merge", "true");
}
formData.append(
"content",
new Blob([new Uint8Array(contentBytes)])
);
this.logger.debug(
`Creating document with relative path ${relativePath} (forceMerge: ${forceMerge})`
`Creating document with relative path ${relativePath}`
);
const response = await this.client(this.getUrl("/documents"), {

View file

@ -369,9 +369,7 @@ export class SyncClient {
this.checkIfDestroyed("syncLocallyCreatedFile");
this.fileChangeNotifier.notifyOfFileChange(relativePath);
return this.syncer.syncLocallyCreatedFile(relativePath, {
forceMerge: false
});
return this.syncer.syncLocallyCreatedFile(relativePath,);
}
public async syncLocallyDeletedFile(

View file

@ -82,7 +82,6 @@ export class Syncer {
public async syncLocallyCreatedFile(
relativePath: RelativePath,
{ forceMerge }: { forceMerge: boolean }
): Promise<void> {
if (
this.database.getLatestDocumentByRelativePath(relativePath)
@ -231,7 +230,7 @@ export class Syncer {
await this.syncQueue.add(async () =>
this.unrestrictedSyncer.unrestrictedSyncLocallyCreatedOrUpdatedFile({
oldPath,
document: document!
document
})
);
@ -441,7 +440,7 @@ export class Syncer {
}
}
type Instruction = { "type": "update" | "create", relativePath: string, oldPath?: string };
interface Instruction { "type": "update" | "create", relativePath: string, oldPath?: string }
const instructions: (Instruction | undefined)[] = await awaitAll(
allLocalFiles.map(async (relativePath) => {
if (
@ -536,10 +535,10 @@ export class Syncer {
if (instruction.type === "update") {
// We're outside of the pqueue, so we need to call the public wrapper
return await this.syncLocallyUpdatedFile({
await this.syncLocallyUpdatedFile({
oldPath: instruction.oldPath,
relativePath: instruction.relativePath
});
}); return;
}
}));
@ -553,7 +552,7 @@ export class Syncer {
if (instruction.type === "create") {
// We're outside of the pqueue, so we need to call the public wrapper
return await this.syncLocallyCreatedFile(instruction.relativePath, { forceMerge: true });
await this.syncLocallyCreatedFile(instruction.relativePath,); return;
}
}));

View file

@ -66,14 +66,12 @@ export class UnrestrictedSyncer {
public async unrestrictedSyncLocallyCreatedOrUpdatedFile({
oldPath,
document,
forceMerge,
// We use the same code path for both local and remote updates. We need to force the update
// if there are no local changes but we know that the remote version is newer.
force = false
}: {
oldPath?: RelativePath;
force?: boolean;
forceMerge?: boolean
document: DocumentRecord;
}): Promise<void> {
@ -128,7 +126,6 @@ export class UnrestrictedSyncer {
const response = await this.syncService.create({
relativePath: originalRelativePath,
contentBytes,
forceMerge
});
await this.handleMaybeMergingResponse({