mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-09-01 16:27:07 +00:00
Route transfer stops through provider capabilities
This commit is contained in:
@@ -41,6 +41,7 @@ import {
|
|||||||
supportedOpenReplicationContinuous,
|
supportedOpenReplicationContinuous,
|
||||||
supportedOpenReplicationOneShot,
|
supportedOpenReplicationOneShot,
|
||||||
supportedOpenReplicationUnattended,
|
supportedOpenReplicationUnattended,
|
||||||
|
supportedStopActiveTransfer,
|
||||||
} from "@vrtmrz/livesync-commonlib/replication";
|
} from "@vrtmrz/livesync-commonlib/replication";
|
||||||
import { LiveSyncCouchDBReplicator } from "@vrtmrz/livesync-commonlib/compat/replication/couchdb/LiveSyncReplicator";
|
import { LiveSyncCouchDBReplicator } from "@vrtmrz/livesync-commonlib/compat/replication/couchdb/LiveSyncReplicator";
|
||||||
import { LiveSyncJournalReplicator } from "@vrtmrz/livesync-commonlib/compat/replication/journal/LiveSyncJournalReplicator";
|
import { LiveSyncJournalReplicator } from "@vrtmrz/livesync-commonlib/compat/replication/journal/LiveSyncJournalReplicator";
|
||||||
@@ -165,6 +166,7 @@ export class LiveSyncBaseCore<
|
|||||||
userInitiatedOneShot: supportedOpenReplicationOneShot(),
|
userInitiatedOneShot: supportedOpenReplicationOneShot(),
|
||||||
unattendedOneShot: supportedOpenReplicationUnattended(),
|
unattendedOneShot: supportedOpenReplicationUnattended(),
|
||||||
continuous: supportedOpenReplicationContinuous(),
|
continuous: supportedOpenReplicationContinuous(),
|
||||||
|
stopActiveTransfer: supportedStopActiveTransfer(),
|
||||||
},
|
},
|
||||||
[REMOTE_MINIO]: {
|
[REMOTE_MINIO]: {
|
||||||
kind: REMOTE_MINIO,
|
kind: REMOTE_MINIO,
|
||||||
@@ -175,6 +177,7 @@ export class LiveSyncBaseCore<
|
|||||||
userInitiatedOneShot: supportedOpenReplicationOneShot(),
|
userInitiatedOneShot: supportedOpenReplicationOneShot(),
|
||||||
unattendedOneShot: supportedOpenReplicationUnattended(),
|
unattendedOneShot: supportedOpenReplicationUnattended(),
|
||||||
continuous: CAPABILITY_NOT_APPLICABLE,
|
continuous: CAPABILITY_NOT_APPLICABLE,
|
||||||
|
stopActiveTransfer: supportedStopActiveTransfer(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
this.services.replicator.registerReplicatorProviderDefinitions(definitions);
|
this.services.replicator.registerReplicatorProviderDefinitions(definitions);
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ export class ModuleBasicMenu extends AbstractModule {
|
|||||||
checkCallback: (checking) => {
|
checkCallback: (checking) => {
|
||||||
if (!this.settings.useAdvancedMode) return false;
|
if (!this.settings.useAdvancedMode) return false;
|
||||||
if (!checking) {
|
if (!checking) {
|
||||||
this.core.replicator.terminateSync();
|
fireAndForget(() => this.services.replication.stopActiveTransfer());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ function createFixture() {
|
|||||||
},
|
},
|
||||||
replication: {
|
replication: {
|
||||||
replicateUserInitiated: vi.fn(async () => ({ status: "completed" as const })),
|
replicateUserInitiated: vi.fn(async () => ({ status: "completed" as const })),
|
||||||
|
stopActiveTransfer: vi.fn(async () => ({ status: "completed" as const })),
|
||||||
},
|
},
|
||||||
vault: {
|
vault: {
|
||||||
getActiveFilePath: vi.fn((): string | null => "note.md"),
|
getActiveFilePath: vi.fn((): string | null => "note.md"),
|
||||||
@@ -136,6 +137,19 @@ describe("ModuleBasicMenu command palette", () => {
|
|||||||
expect(fixture.getCommand("livesync-abortsync").checkCallback?.(true)).toBe(true);
|
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 () => {
|
it("keeps active-file database information available and opens it in a copy dialogue", async () => {
|
||||||
const fixture = createFixture();
|
const fixture = createFixture();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user