mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-08-29 14:57:05 +00:00
Route transfer stops through provider capabilities
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user