mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-30 04:53:21 +00:00
Fix automatic P2P settings restoration in CLI host mode
This commit is contained in:
1 parent
0956663f7b
commit
3e2b4dcb3b
16 files changed
+944
-25
No files matched your search
@@ -5,6 +5,7 @@ import { compatGlobal } from "@vrtmrz/livesync-commonlib/compat/common/coreEnvFu
|
||||
import { LiveSyncError } from "@vrtmrz/livesync-commonlib/compat/common/LSError";
|
||||
import type { P2PPeerConnectionMetrics, P2PServiceViews } from "@vrtmrz/livesync-commonlib/p2p";
|
||||
import { fsPromises } from "@vrtmrz/livesync-commonlib/node";
|
||||
import type { CLIP2PHostSettings } from "./types";
|
||||
|
||||
type CLIP2PPeer = {
|
||||
peerId: string;
|
||||
@@ -191,8 +192,11 @@ export async function syncWithPeer(
|
||||
/** Connect the headless P2P host and transfer transport ownership to the caller. */
|
||||
export async function openP2PHost(
|
||||
core: LiveSyncBaseCore<ServiceContext, never>,
|
||||
p2pService: CLIP2PService | undefined
|
||||
p2pService: CLIP2PService | undefined,
|
||||
originalP2PSettings: CLIP2PHostSettings
|
||||
): Promise<CLIP2PService> {
|
||||
// Restore only P2P policy after database readiness, before peer discovery.
|
||||
await core.services.setting.applyPartial(originalP2PSettings);
|
||||
const service = requireP2PService(core, p2pService);
|
||||
await service.transportLifecycle.connect();
|
||||
return service;
|
||||
|
||||
Reference in new issue
Block a user