Route transfer stops through provider capabilities

This commit is contained in:
vorotamoroz
2026-08-27 13:18:46 +00:00
parent 8e5b058eef
commit 7cf4ec49ed
3 changed files with 18 additions and 1 deletions
+3
View File
@@ -41,6 +41,7 @@ import {
supportedOpenReplicationContinuous,
supportedOpenReplicationOneShot,
supportedOpenReplicationUnattended,
supportedStopActiveTransfer,
} from "@vrtmrz/livesync-commonlib/replication";
import { LiveSyncCouchDBReplicator } from "@vrtmrz/livesync-commonlib/compat/replication/couchdb/LiveSyncReplicator";
import { LiveSyncJournalReplicator } from "@vrtmrz/livesync-commonlib/compat/replication/journal/LiveSyncJournalReplicator";
@@ -165,6 +166,7 @@ export class LiveSyncBaseCore<
userInitiatedOneShot: supportedOpenReplicationOneShot(),
unattendedOneShot: supportedOpenReplicationUnattended(),
continuous: supportedOpenReplicationContinuous(),
stopActiveTransfer: supportedStopActiveTransfer(),
},
[REMOTE_MINIO]: {
kind: REMOTE_MINIO,
@@ -175,6 +177,7 @@ export class LiveSyncBaseCore<
userInitiatedOneShot: supportedOpenReplicationOneShot(),
unattendedOneShot: supportedOpenReplicationUnattended(),
continuous: CAPABILITY_NOT_APPLICABLE,
stopActiveTransfer: supportedStopActiveTransfer(),
},
});
this.services.replicator.registerReplicatorProviderDefinitions(definitions);
+1 -1
View File
@@ -89,7 +89,7 @@ export class ModuleBasicMenu extends AbstractModule {
checkCallback: (checking) => {
if (!this.settings.useAdvancedMode) return false;
if (!checking) {
this.core.replicator.terminateSync();
fireAndForget(() => this.services.replication.stopActiveTransfer());
}
return true;
},
@@ -26,6 +26,7 @@ function createFixture() {
},
replication: {
replicateUserInitiated: vi.fn(async () => ({ status: "completed" as const })),
stopActiveTransfer: vi.fn(async () => ({ status: "completed" as const })),
},
vault: {
getActiveFilePath: vi.fn((): string | null => "note.md"),
@@ -136,6 +137,19 @@ describe("ModuleBasicMenu command palette", () => {
expect(fixture.getCommand("livesync-abortsync").checkCallback?.(true)).toBe(true);
});
it("routes an explicit stop through the active provider capability", async () => {
const fixture = createFixture();
fixture.settings.useAdvancedMode = true;
await fixture.module._everyOnloadStart();
expect(fixture.getCommand("livesync-abortsync").checkCallback?.(false)).toBe(true);
await vi.waitFor(() => {
expect(fixture.services.replication.stopActiveTransfer).toHaveBeenCalledOnce();
});
expect(fixture.core.replicator.terminateSync).not.toHaveBeenCalled();
});
it("keeps active-file database information available and opens it in a copy dialogue", async () => {
const fixture = createFixture();