@jr2804/livesync-cli 1.0.16-cli.1 → 1.0.21-cli.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +665 -330
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4028,6 +4028,16 @@ var RemoteTypes = {
|
|
|
4028
4028
|
var REMOTE_COUCHDB = RemoteTypes.REMOTE_COUCHDB;
|
|
4029
4029
|
var REMOTE_MINIO = RemoteTypes.REMOTE_MINIO;
|
|
4030
4030
|
var REMOTE_P2P = RemoteTypes.REMOTE_P2P;
|
|
4031
|
+
var P2PConnectionPaths = {
|
|
4032
|
+
Automatic: "automatic",
|
|
4033
|
+
Relay: "relay"
|
|
4034
|
+
};
|
|
4035
|
+
var P2PMessageSizePresets = {
|
|
4036
|
+
Standard: 15360,
|
|
4037
|
+
Reduced: 2048,
|
|
4038
|
+
Conservative: 1024,
|
|
4039
|
+
MaximumCompatibility: 800
|
|
4040
|
+
};
|
|
4031
4041
|
var E2EEAlgorithms = {
|
|
4032
4042
|
V1: "",
|
|
4033
4043
|
V2: "v2",
|
|
@@ -4053,6 +4063,33 @@ var ChunkAlgorithms = {
|
|
|
4053
4063
|
RabinKarp: "v3-rabin-karp"
|
|
4054
4064
|
};
|
|
4055
4065
|
//#endregion
|
|
4066
|
+
//#region ../../../node_modules/@vrtmrz/livesync-commonlib/dist/common/models/setting.p2p.js
|
|
4067
|
+
function normaliseP2PMaxWirePayloadBytes(value) {
|
|
4068
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < P2PMessageSizePresets.MaximumCompatibility || value > P2PMessageSizePresets.Standard) return P2PMessageSizePresets.Standard;
|
|
4069
|
+
return value;
|
|
4070
|
+
}
|
|
4071
|
+
function normaliseP2PConnectionPath(value) {
|
|
4072
|
+
return value === P2PConnectionPaths.Relay ? P2PConnectionPaths.Relay : P2PConnectionPaths.Automatic;
|
|
4073
|
+
}
|
|
4074
|
+
function splitP2PTurnServerUrls(value) {
|
|
4075
|
+
return value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
4076
|
+
}
|
|
4077
|
+
function isValidP2PTurnServerUrl(value) {
|
|
4078
|
+
const candidate = value.trim();
|
|
4079
|
+
if (!candidate || /\s/.test(candidate)) return false;
|
|
4080
|
+
try {
|
|
4081
|
+
const parsed = new URL(candidate);
|
|
4082
|
+
const protocol = parsed.protocol.toLowerCase();
|
|
4083
|
+
if (protocol !== "turn:" && protocol !== "turns:") return false;
|
|
4084
|
+
return (parsed.hostname || parsed.pathname).length > 0;
|
|
4085
|
+
} catch {
|
|
4086
|
+
return false;
|
|
4087
|
+
}
|
|
4088
|
+
}
|
|
4089
|
+
function hasValidP2PTurnServerUrl(value) {
|
|
4090
|
+
return splitP2PTurnServerUrls(value).some(isValidP2PTurnServerUrl);
|
|
4091
|
+
}
|
|
4092
|
+
//#endregion
|
|
4056
4093
|
//#region ../../../node_modules/@vrtmrz/livesync-commonlib/dist/common/models/setting.const.preferred.js
|
|
4057
4094
|
var PREFERRED_BASE = {
|
|
4058
4095
|
syncMaxSizeInMB: 50,
|
|
@@ -4086,6 +4123,8 @@ var P2P_DEFAULT_SETTINGS = {
|
|
|
4086
4123
|
P2P_turnServers: "",
|
|
4087
4124
|
P2P_turnUsername: "",
|
|
4088
4125
|
P2P_turnCredential: "",
|
|
4126
|
+
P2P_maxWirePayloadBytes: P2PMessageSizePresets.Standard,
|
|
4127
|
+
P2P_connectionPath: P2PConnectionPaths.Automatic,
|
|
4089
4128
|
P2P_useDiagRTC: false
|
|
4090
4129
|
};
|
|
4091
4130
|
var SETTINGS_SCHEMA_DEFAULTS = {
|
|
@@ -4522,6 +4561,14 @@ var configurationNames = {
|
|
|
4522
4561
|
desc: "The credential/password for the TURN servers.",
|
|
4523
4562
|
isHidden: true
|
|
4524
4563
|
},
|
|
4564
|
+
P2P_maxWirePayloadBytes: {
|
|
4565
|
+
name: "P2P Message Size",
|
|
4566
|
+
desc: "The maximum outgoing RPC wire payload before Commonlib splits it for the P2P transport."
|
|
4567
|
+
},
|
|
4568
|
+
P2P_connectionPath: {
|
|
4569
|
+
name: "Connection Path",
|
|
4570
|
+
desc: "Select the WebRTC route automatically or require a configured TURN relay."
|
|
4571
|
+
},
|
|
4525
4572
|
useOnlyLocalChunk: {
|
|
4526
4573
|
name: "Use Only Local Chunks",
|
|
4527
4574
|
desc: "If enabled, the plugin will not attempt to connect to the remote database even if the chunk was not found locally.",
|
|
@@ -4545,10 +4592,6 @@ function statusDisplay(status) {
|
|
|
4545
4592
|
if (status == "BETA") return ` (Beta)`;
|
|
4546
4593
|
return ` (${status})`;
|
|
4547
4594
|
}
|
|
4548
|
-
function confName(key, alt = "") {
|
|
4549
|
-
if (key in configurationNames) return `${configurationNames[key]?.name}${statusDisplay(configurationNames[key]?.status)}`;
|
|
4550
|
-
else return `${alt || ""}`;
|
|
4551
|
-
}
|
|
4552
4595
|
//#endregion
|
|
4553
4596
|
//#region ../../../node_modules/@vrtmrz/livesync-commonlib/dist/common/models/sync.definition.js
|
|
4554
4597
|
var ProtocolVersions = {
|
|
@@ -7068,8 +7111,7 @@ var ReplicationService = class extends ServiceBase {
|
|
|
7068
7111
|
}
|
|
7069
7112
|
return activeReplicator;
|
|
7070
7113
|
}
|
|
7071
|
-
async
|
|
7072
|
-
if (!this.appLifecycleService.isReady()) return false;
|
|
7114
|
+
async performReplicateAllToRemote(showingNotice) {
|
|
7073
7115
|
if (!await this.onBeforeReplicate(showingNotice)) {
|
|
7074
7116
|
this._log(this.context.translate("Replicator.Message.SomeModuleFailed"), 64);
|
|
7075
7117
|
return false;
|
|
@@ -7082,8 +7124,7 @@ var ReplicationService = class extends ServiceBase {
|
|
|
7082
7124
|
if (checkResult == "CHECKAGAIN") return await activeReplicator.replicateAllToServer(currentSettings, showingNotice);
|
|
7083
7125
|
return !checkResult;
|
|
7084
7126
|
}
|
|
7085
|
-
async
|
|
7086
|
-
if (!this.appLifecycleService.isReady()) return false;
|
|
7127
|
+
async performReplicateAllFromRemote(showingNotice) {
|
|
7087
7128
|
const activeReplicator = this.getActiveReplicatorFor("fetching data from remote");
|
|
7088
7129
|
if (!activeReplicator) return false;
|
|
7089
7130
|
const currentSettings = this.settingService.currentSettings();
|
|
@@ -7092,6 +7133,40 @@ var ReplicationService = class extends ServiceBase {
|
|
|
7092
7133
|
if (checkResult == "CHECKAGAIN") return await activeReplicator.replicateAllFromServer(currentSettings, showingNotice);
|
|
7093
7134
|
return !checkResult;
|
|
7094
7135
|
}
|
|
7136
|
+
async replicateAllToRemote(showingNotice = false) {
|
|
7137
|
+
if (!this.appLifecycleService.isReady()) return false;
|
|
7138
|
+
return await this.performReplicateAllToRemote(showingNotice);
|
|
7139
|
+
}
|
|
7140
|
+
async replicateAllFromRemote(showingNotice = false) {
|
|
7141
|
+
if (!this.appLifecycleService.isReady()) return false;
|
|
7142
|
+
return await this.performReplicateAllFromRemote(showingNotice);
|
|
7143
|
+
}
|
|
7144
|
+
/**
|
|
7145
|
+
* Perform a full upload owned by an active rebuild while the physical database is ready.
|
|
7146
|
+
*
|
|
7147
|
+
* This concrete maintenance entry point is intentionally absent from `IReplicationService`;
|
|
7148
|
+
* it is not a general application-readiness bypass.
|
|
7149
|
+
*/
|
|
7150
|
+
async replicateAllToRemoteForRebuild(showingNotice = false) {
|
|
7151
|
+
if (!this.databaseService.isDatabaseReady()) {
|
|
7152
|
+
this._log("The selected local database is not ready for the rebuild upload.", 64);
|
|
7153
|
+
return false;
|
|
7154
|
+
}
|
|
7155
|
+
return await this.performReplicateAllToRemote(showingNotice);
|
|
7156
|
+
}
|
|
7157
|
+
/**
|
|
7158
|
+
* Perform a full download owned by an active rebuild while the physical database is ready.
|
|
7159
|
+
*
|
|
7160
|
+
* This concrete maintenance entry point is intentionally absent from `IReplicationService`;
|
|
7161
|
+
* it is not a general application-readiness bypass.
|
|
7162
|
+
*/
|
|
7163
|
+
async replicateAllFromRemoteForRebuild(showingNotice = false) {
|
|
7164
|
+
if (!this.databaseService.isDatabaseReady()) {
|
|
7165
|
+
this._log("The selected local database is not ready for the rebuild download.", 64);
|
|
7166
|
+
return false;
|
|
7167
|
+
}
|
|
7168
|
+
return await this.performReplicateAllFromRemote(showingNotice);
|
|
7169
|
+
}
|
|
7095
7170
|
_getReplicatorAndPerform(action, perform) {
|
|
7096
7171
|
const activeReplicator = this.getActiveReplicatorFor(action);
|
|
7097
7172
|
if (!activeReplicator) return Promise.resolve();
|
|
@@ -7189,6 +7264,18 @@ var ReplicatorService = class extends ServiceBase {
|
|
|
7189
7264
|
this._replicatorType = void 0;
|
|
7190
7265
|
return true;
|
|
7191
7266
|
}
|
|
7267
|
+
async discardFailedReplicator(replicator) {
|
|
7268
|
+
if (this._activeReplicator === replicator) {
|
|
7269
|
+
this._activeReplicator = void 0;
|
|
7270
|
+
this._replicatorType = void 0;
|
|
7271
|
+
}
|
|
7272
|
+
try {
|
|
7273
|
+
await Promise.resolve(replicator.closeReplication());
|
|
7274
|
+
} catch (error) {
|
|
7275
|
+
this._log("Failed to close a replicator after its initialisation failed.", 16);
|
|
7276
|
+
this._log(error, 16);
|
|
7277
|
+
}
|
|
7278
|
+
}
|
|
7192
7279
|
async _initialiseReplicator() {
|
|
7193
7280
|
const message = this.context.translate("Replicator.Message.InitialiseFatalError");
|
|
7194
7281
|
const setting = this.settingService.currentSettings();
|
|
@@ -7228,19 +7315,23 @@ var ReplicatorService = class extends ServiceBase {
|
|
|
7228
7315
|
this._replicatorType = replicatorType;
|
|
7229
7316
|
this.replicationStatics.value = { ...DEFAULT_REPLICATION_STATICS };
|
|
7230
7317
|
await yieldMicrotask();
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7318
|
+
try {
|
|
7319
|
+
if (!await newReplicator.initializeDatabaseForReplication()) {
|
|
7320
|
+
this._log("Failed to initialise the replicator's local node information.");
|
|
7321
|
+
await this.discardFailedReplicator(newReplicator);
|
|
7322
|
+
this._unresolvedErrorManager.showError(message, 64);
|
|
7323
|
+
return false;
|
|
7324
|
+
}
|
|
7325
|
+
if (!await this.onReplicatorInitialised()) {
|
|
7326
|
+
this._log("Failed to initialise the replicator, onReplicatorInitialised reported some problems.");
|
|
7327
|
+
await this.discardFailedReplicator(newReplicator);
|
|
7328
|
+
this._unresolvedErrorManager.showError(message, 64);
|
|
7329
|
+
return false;
|
|
7330
|
+
}
|
|
7331
|
+
} catch (error) {
|
|
7332
|
+
await this.discardFailedReplicator(newReplicator);
|
|
7242
7333
|
this._unresolvedErrorManager.showError(message, 64);
|
|
7243
|
-
|
|
7334
|
+
throw error;
|
|
7244
7335
|
}
|
|
7245
7336
|
const remoteTypeDisplay = replicatorType === RemoteTypes.REMOTE_COUCHDB ? "CouchDB" : replicatorType;
|
|
7246
7337
|
this._log(`Replicator (${remoteTypeDisplay}) initialised and activated`, 16);
|
|
@@ -10414,10 +10505,10 @@ var HeadlessAPIService = class extends InjectableAPIService {
|
|
|
10414
10505
|
return "headless-app";
|
|
10415
10506
|
}
|
|
10416
10507
|
getAppVersion() {
|
|
10417
|
-
return `1.0.
|
|
10508
|
+
return `1.0.21`;
|
|
10418
10509
|
}
|
|
10419
10510
|
getPluginVersion() {
|
|
10420
|
-
return `1.0.
|
|
10511
|
+
return `1.0.21`;
|
|
10421
10512
|
}
|
|
10422
10513
|
getPlatform() {
|
|
10423
10514
|
return "server";
|
|
@@ -11042,7 +11133,9 @@ var ConnectionStringParser = class {
|
|
|
11042
11133
|
P2P_AutoBroadcast: searchParams.get("autoBroadcast") === "true",
|
|
11043
11134
|
P2P_turnServers: searchParams.get("turnServers") || "",
|
|
11044
11135
|
P2P_turnUsername: searchParams.get("turnUser") || "",
|
|
11045
|
-
P2P_turnCredential: searchParams.get("turnPass") || ""
|
|
11136
|
+
P2P_turnCredential: searchParams.get("turnPass") || "",
|
|
11137
|
+
P2P_maxWirePayloadBytes: normaliseP2PMaxWirePayloadBytes(Number(searchParams.get("maxWirePayloadBytes"))),
|
|
11138
|
+
P2P_connectionPath: normaliseP2PConnectionPath(searchParams.get("connectionPath"))
|
|
11046
11139
|
};
|
|
11047
11140
|
}
|
|
11048
11141
|
static serializeP2P(settings) {
|
|
@@ -11055,6 +11148,8 @@ var ConnectionStringParser = class {
|
|
|
11055
11148
|
if (settings.P2P_turnServers) searchParams.set("turnServers", settings.P2P_turnServers);
|
|
11056
11149
|
if (settings.P2P_turnUsername) searchParams.set("turnUser", settings.P2P_turnUsername);
|
|
11057
11150
|
if (settings.P2P_turnCredential) searchParams.set("turnPass", settings.P2P_turnCredential);
|
|
11151
|
+
searchParams.set("maxWirePayloadBytes", String(normaliseP2PMaxWirePayloadBytes(settings.P2P_maxWirePayloadBytes)));
|
|
11152
|
+
searchParams.set("connectionPath", normaliseP2PConnectionPath(settings.P2P_connectionPath));
|
|
11058
11153
|
return `sls+p2p://${settings.P2P_passphrase ? `:${encodeURIComponent(settings.P2P_passphrase)}@` : ""}${encodeURIComponent(settings.P2P_roomID)}${searchParams.toString() ? `?${searchParams.toString()}` : ""}`;
|
|
11059
11154
|
}
|
|
11060
11155
|
};
|
|
@@ -18844,16 +18939,14 @@ var LiveSyncLocalDB = class {
|
|
|
18844
18939
|
async _prepareHashFunctions() {
|
|
18845
18940
|
await this._managers?.prepareHashFunction();
|
|
18846
18941
|
}
|
|
18847
|
-
onunload() {
|
|
18848
|
-
this.env.services.databaseEvents.onUnloadDatabase(this);
|
|
18849
|
-
this.localDatabase.removeAllListeners();
|
|
18850
|
-
}
|
|
18851
18942
|
refreshSettings() {
|
|
18852
18943
|
const settings = this.env.services.setting.currentSettings();
|
|
18853
18944
|
this.settings = settings;
|
|
18854
18945
|
this._prepareHashFunctions();
|
|
18855
18946
|
}
|
|
18856
18947
|
offRemoteChunkFetchedHandler;
|
|
18948
|
+
databaseCloseCleanup;
|
|
18949
|
+
databaseUnloadNotification;
|
|
18857
18950
|
constructor(dbname, env) {
|
|
18858
18951
|
this.auth = {
|
|
18859
18952
|
username: "",
|
|
@@ -18864,12 +18957,68 @@ var LiveSyncLocalDB = class {
|
|
|
18864
18957
|
this._log = createInstanceLogFunction("LiveSyncLocalDB", this.env.services.API);
|
|
18865
18958
|
this.refreshSettings();
|
|
18866
18959
|
}
|
|
18960
|
+
/** Notify dependent services at most once for each physical database lifecycle. */
|
|
18961
|
+
notifyDatabaseUnload() {
|
|
18962
|
+
if (!this.databaseUnloadNotification) this.databaseUnloadNotification = Promise.resolve().then(async () => {
|
|
18963
|
+
await this.env.services.databaseEvents.onUnloadDatabase(this);
|
|
18964
|
+
});
|
|
18965
|
+
return this.databaseUnloadNotification;
|
|
18966
|
+
}
|
|
18967
|
+
onunload() {
|
|
18968
|
+
this.notifyDatabaseUnload();
|
|
18969
|
+
}
|
|
18867
18970
|
async close() {
|
|
18868
18971
|
this._log("Database closed (by close)");
|
|
18869
18972
|
this.isReady = false;
|
|
18870
18973
|
this.offRemoteChunkFetchedHandler?.();
|
|
18871
|
-
|
|
18872
|
-
|
|
18974
|
+
this.offRemoteChunkFetchedHandler = void 0;
|
|
18975
|
+
if (this.localDatabase != null) {
|
|
18976
|
+
const database = this.localDatabase;
|
|
18977
|
+
await database.close();
|
|
18978
|
+
if (this.databaseCloseCleanup?.database === database) await this.databaseCloseCleanup.promise;
|
|
18979
|
+
if (this.localDatabase === database) this.localDatabase = null;
|
|
18980
|
+
}
|
|
18981
|
+
this._managers = void 0;
|
|
18982
|
+
await this.notifyDatabaseUnload();
|
|
18983
|
+
}
|
|
18984
|
+
async teardownDatabaseDependencies(managers) {
|
|
18985
|
+
try {
|
|
18986
|
+
await Promise.resolve(this.env.services.replicator.getActiveReplicator()?.closeReplication());
|
|
18987
|
+
} catch (error) {
|
|
18988
|
+
this._log("Failed to close replication while tearing down the local database.", 16);
|
|
18989
|
+
this._log(error, 16);
|
|
18990
|
+
}
|
|
18991
|
+
try {
|
|
18992
|
+
await managers.teardownManagers();
|
|
18993
|
+
} catch (error) {
|
|
18994
|
+
this._log("Failed to tear down managers while closing the local database.", 16);
|
|
18995
|
+
this._log(error, 16);
|
|
18996
|
+
}
|
|
18997
|
+
}
|
|
18998
|
+
async rollbackFailedInitialisation(database, managers) {
|
|
18999
|
+
this.isReady = false;
|
|
19000
|
+
this.offRemoteChunkFetchedHandler?.();
|
|
19001
|
+
this.offRemoteChunkFetchedHandler = void 0;
|
|
19002
|
+
const closeCleanup = this.databaseCloseCleanup?.database === database ? this.databaseCloseCleanup : void 0;
|
|
19003
|
+
if (closeCleanup) await closeCleanup.promise;
|
|
19004
|
+
else {
|
|
19005
|
+
database.removeAllListeners();
|
|
19006
|
+
await this.teardownDatabaseDependencies(managers);
|
|
19007
|
+
try {
|
|
19008
|
+
await database.close();
|
|
19009
|
+
} catch (error) {
|
|
19010
|
+
this._log("Failed to close the database after its initialisation was rejected.", 16);
|
|
19011
|
+
this._log(error, 16);
|
|
19012
|
+
}
|
|
19013
|
+
}
|
|
19014
|
+
if (this.localDatabase === database) this.localDatabase = null;
|
|
19015
|
+
if (this._managers === managers) this._managers = void 0;
|
|
19016
|
+
try {
|
|
19017
|
+
await this.notifyDatabaseUnload();
|
|
19018
|
+
} catch (error) {
|
|
19019
|
+
this._log("A database unload handler failed after initialisation was rejected.", 16);
|
|
19020
|
+
this._log(error, 16);
|
|
19021
|
+
}
|
|
18873
19022
|
}
|
|
18874
19023
|
onNewLeaf(chunk) {
|
|
18875
19024
|
this.managers.chunkManager?.emitEvent(EVENT_CHUNK_FETCHED, chunk);
|
|
@@ -18886,6 +19035,7 @@ var LiveSyncLocalDB = class {
|
|
|
18886
19035
|
revs_limit: 100,
|
|
18887
19036
|
deterministic_revs: true
|
|
18888
19037
|
});
|
|
19038
|
+
this.databaseUnloadNotification = void 0;
|
|
18889
19039
|
const manager = new LiveSyncManagers({
|
|
18890
19040
|
database: this.localDatabase,
|
|
18891
19041
|
APIService: this.env.services.API,
|
|
@@ -18895,31 +19045,45 @@ var LiveSyncLocalDB = class {
|
|
|
18895
19045
|
databaseService: this.env.services.database
|
|
18896
19046
|
});
|
|
18897
19047
|
this._managers = manager;
|
|
18898
|
-
|
|
18899
|
-
this.
|
|
18900
|
-
|
|
18901
|
-
|
|
18902
|
-
|
|
18903
|
-
|
|
18904
|
-
|
|
18905
|
-
|
|
18906
|
-
this.
|
|
18907
|
-
this.
|
|
18908
|
-
this.
|
|
18909
|
-
|
|
18910
|
-
|
|
18911
|
-
|
|
18912
|
-
|
|
18913
|
-
|
|
18914
|
-
|
|
18915
|
-
|
|
18916
|
-
|
|
18917
|
-
|
|
18918
|
-
|
|
18919
|
-
|
|
19048
|
+
const openedDatabase = this.localDatabase;
|
|
19049
|
+
this.databaseCloseCleanup = void 0;
|
|
19050
|
+
try {
|
|
19051
|
+
if (!await this.env.services.databaseEvents.onDatabaseInitialisation(this)) {
|
|
19052
|
+
await this.rollbackFailedInitialisation(openedDatabase, manager);
|
|
19053
|
+
this._log("Database initialisation was rejected by a required module.", 64);
|
|
19054
|
+
return false;
|
|
19055
|
+
}
|
|
19056
|
+
this._log("Opening Database...");
|
|
19057
|
+
this._log("Database info", 16);
|
|
19058
|
+
this._log(JSON.stringify(await openedDatabase.info(), null, 2), 16);
|
|
19059
|
+
await manager.initialise();
|
|
19060
|
+
openedDatabase.on("close", () => {
|
|
19061
|
+
this._log("Database closed.");
|
|
19062
|
+
this.isReady = false;
|
|
19063
|
+
openedDatabase.removeAllListeners();
|
|
19064
|
+
if (this.databaseCloseCleanup?.database !== openedDatabase) this.databaseCloseCleanup = {
|
|
19065
|
+
database: openedDatabase,
|
|
19066
|
+
promise: this.teardownDatabaseDependencies(manager)
|
|
19067
|
+
};
|
|
19068
|
+
});
|
|
19069
|
+
const _instance = new FallbackWeakRef(this);
|
|
19070
|
+
const unload = this.env.services.context.events.onEvent(REMOTE_CHUNK_FETCHED, (chunk) => {
|
|
19071
|
+
if (_instance.deref() == null) unload();
|
|
19072
|
+
_instance.deref()?.onNewLeaf(chunk);
|
|
19073
|
+
});
|
|
19074
|
+
this.offRemoteChunkFetchedHandler = unload;
|
|
19075
|
+
this.isReady = true;
|
|
19076
|
+
if (!await this.env.services.databaseEvents.onDatabaseHasReady() || this.localDatabase !== openedDatabase || !this.isReady) {
|
|
19077
|
+
await this.rollbackFailedInitialisation(openedDatabase, manager);
|
|
19078
|
+
this._log("Some module has prevented the database from being ready. The database is initialised but not ready for use.", 64);
|
|
19079
|
+
return false;
|
|
19080
|
+
}
|
|
19081
|
+
this._log("Database is now ready.");
|
|
19082
|
+
return true;
|
|
19083
|
+
} catch (error) {
|
|
19084
|
+
await this.rollbackFailedInitialisation(openedDatabase, manager);
|
|
19085
|
+
throw error;
|
|
18920
19086
|
}
|
|
18921
|
-
this._log("Database is now ready.");
|
|
18922
|
-
return true;
|
|
18923
19087
|
}
|
|
18924
19088
|
/**
|
|
18925
19089
|
* Retrieve all used and existing chunks in the database.
|
|
@@ -18992,6 +19156,7 @@ var LiveSyncLocalDB = class {
|
|
|
18992
19156
|
};
|
|
18993
19157
|
}
|
|
18994
19158
|
async resetDatabase() {
|
|
19159
|
+
this.isReady = false;
|
|
18995
19160
|
await this.managers.teardownManagers();
|
|
18996
19161
|
this.env.services.replicator.getActiveReplicator()?.closeReplication();
|
|
18997
19162
|
if (!await this.env.services.databaseEvents.onResetDatabase(this)) {
|
|
@@ -18999,10 +19164,12 @@ var LiveSyncLocalDB = class {
|
|
|
18999
19164
|
return false;
|
|
19000
19165
|
}
|
|
19001
19166
|
Logger("Database closed for reset Database.");
|
|
19002
|
-
this.isReady = false;
|
|
19003
19167
|
await this.localDatabase.destroy();
|
|
19004
19168
|
this.localDatabase = null;
|
|
19005
|
-
await this.initializeDatabase()
|
|
19169
|
+
if (!await this.initializeDatabase()) {
|
|
19170
|
+
this._log("Local Database could not be reinitialised after reset.", 64);
|
|
19171
|
+
return false;
|
|
19172
|
+
}
|
|
19006
19173
|
this._log("Local Database Reset", 64);
|
|
19007
19174
|
return true;
|
|
19008
19175
|
}
|
|
@@ -19175,9 +19342,7 @@ var DatabaseService = class extends ServiceBase {
|
|
|
19175
19342
|
_localDatabase = null;
|
|
19176
19343
|
services;
|
|
19177
19344
|
onOpenDatabase = handlers().bailFirstFailure("onOpenDatabase");
|
|
19178
|
-
/**
|
|
19179
|
-
* Called after the local database has been reset.
|
|
19180
|
-
*/
|
|
19345
|
+
/** Called after the active database has been reset and successfully reinitialised. */
|
|
19181
19346
|
onDatabaseReset = handlers().bailFirstFailure("onDatabaseReset");
|
|
19182
19347
|
get localDatabase() {
|
|
19183
19348
|
if (!this._localDatabase) throw new Error("Local database is not ready yet.");
|
|
@@ -19210,22 +19375,68 @@ var DatabaseService = class extends ServiceBase {
|
|
|
19210
19375
|
if (this._localDatabase != null) await this._localDatabase.close();
|
|
19211
19376
|
const vaultName = this.services.vault.getVaultName();
|
|
19212
19377
|
this._log(this.context.translate("moduleLocalDatabase.logWaitingForReady"));
|
|
19213
|
-
const
|
|
19378
|
+
const selectedDatabase = new LiveSyncLocalDB(vaultName, { services: {
|
|
19214
19379
|
context: this.context,
|
|
19215
19380
|
...this.services,
|
|
19216
19381
|
...params,
|
|
19217
19382
|
database: this
|
|
19218
|
-
} };
|
|
19219
|
-
this._localDatabase =
|
|
19220
|
-
|
|
19221
|
-
|
|
19383
|
+
} });
|
|
19384
|
+
this._localDatabase = selectedDatabase;
|
|
19385
|
+
try {
|
|
19386
|
+
await this.onOpenDatabase(vaultName);
|
|
19387
|
+
const initialised = await selectedDatabase.initializeDatabase();
|
|
19388
|
+
if (!initialised && this._localDatabase === selectedDatabase) this._localDatabase = null;
|
|
19389
|
+
return initialised;
|
|
19390
|
+
} catch (error) {
|
|
19391
|
+
if (this._localDatabase === selectedDatabase) this._localDatabase = null;
|
|
19392
|
+
throw error;
|
|
19393
|
+
}
|
|
19222
19394
|
}
|
|
19223
19395
|
isDatabaseReady() {
|
|
19224
19396
|
return this._localDatabase != null && this._localDatabase.isReady;
|
|
19225
19397
|
}
|
|
19398
|
+
async discardFailedActiveDatabase(database) {
|
|
19399
|
+
if (this._localDatabase === database) this._localDatabase = null;
|
|
19400
|
+
try {
|
|
19401
|
+
await database.close();
|
|
19402
|
+
} catch (error) {
|
|
19403
|
+
this._log("Failed to close the active database after a rejected lifecycle transition.", 16);
|
|
19404
|
+
this._log(error, 16);
|
|
19405
|
+
}
|
|
19406
|
+
}
|
|
19226
19407
|
async resetDatabase() {
|
|
19227
19408
|
if (!this._localDatabase) return Promise.resolve(true);
|
|
19228
|
-
|
|
19409
|
+
const activeDatabase = this._localDatabase;
|
|
19410
|
+
try {
|
|
19411
|
+
if (!await activeDatabase.resetDatabase()) {
|
|
19412
|
+
await this.discardFailedActiveDatabase(activeDatabase);
|
|
19413
|
+
return false;
|
|
19414
|
+
}
|
|
19415
|
+
if (!await this.onDatabaseReset()) {
|
|
19416
|
+
await this.discardFailedActiveDatabase(activeDatabase);
|
|
19417
|
+
return false;
|
|
19418
|
+
}
|
|
19419
|
+
return true;
|
|
19420
|
+
} catch (error) {
|
|
19421
|
+
await this.discardFailedActiveDatabase(activeDatabase);
|
|
19422
|
+
throw error;
|
|
19423
|
+
}
|
|
19424
|
+
}
|
|
19425
|
+
/**
|
|
19426
|
+
* Reset the database selected by the current settings.
|
|
19427
|
+
*
|
|
19428
|
+
* A `LiveSyncLocalDB` captures its name when constructed, so changing a
|
|
19429
|
+
* suffix does not retarget the active instance. This operation selects and
|
|
19430
|
+
* opens the settings-derived database before resetting it when necessary.
|
|
19431
|
+
* The formerly active physical database is closed but not destroyed.
|
|
19432
|
+
*/
|
|
19433
|
+
async resetDatabaseForCurrentSettings(params) {
|
|
19434
|
+
const selectedDatabaseName = this.services.vault.getVaultName();
|
|
19435
|
+
if (this._localDatabase?.dbname !== selectedDatabaseName) {
|
|
19436
|
+
if (!await this.openDatabase(params)) return false;
|
|
19437
|
+
if (this._localDatabase?.dbname !== selectedDatabaseName) return false;
|
|
19438
|
+
}
|
|
19439
|
+
return await this.resetDatabase();
|
|
19229
19440
|
}
|
|
19230
19441
|
};
|
|
19231
19442
|
//#endregion
|
|
@@ -23572,16 +23783,6 @@ var allMessages = {
|
|
|
23572
23783
|
zh: "显示日志",
|
|
23573
23784
|
"zh-tw": "顯示日誌"
|
|
23574
23785
|
},
|
|
23575
|
-
"moduleMigration.docUri": {
|
|
23576
|
-
def: "https://github.com/vrtmrz/obsidian-livesync/blob/main/README.md#how-to-use",
|
|
23577
|
-
es: "https://github.com/vrtmrz/obsidian-livesync/blob/main/README_ES.md#how-to-use",
|
|
23578
|
-
fr: "https://github.com/vrtmrz/obsidian-livesync/blob/main/README.md#how-to-use",
|
|
23579
|
-
he: "https://github.com/vrtmrz/obsidian-livesync/blob/main/README.md#how-to-use",
|
|
23580
|
-
ja: "https://github.com/vrtmrz/obsidian-livesync/blob/main/README.md#how-to-use",
|
|
23581
|
-
ko: "https://github.com/vrtmrz/obsidian-livesync/blob/main/README.md#how-to-use",
|
|
23582
|
-
ru: "https://github.com/vrtmrz/obsidian-livesync/blob/main/README.md#how-to-use",
|
|
23583
|
-
zh: "https://github.com/vrtmrz/obsidian-livesync/blob/main/docs/zh/README_zh.md#%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8"
|
|
23584
|
-
},
|
|
23585
23786
|
"moduleMigration.fix0256.buttons.checkItLater": {
|
|
23586
23787
|
def: "Check it later",
|
|
23587
23788
|
es: "Comprobarlo más tarde",
|
|
@@ -23813,28 +24014,6 @@ var allMessages = {
|
|
|
23813
24014
|
zh: "您可能已经知道,Self-hosted LiveSync 更改了其默认行为和数据库结构。\n\n值得庆幸的是,在您的时间和努力下,远程数据库似乎已经迁移完成。恭喜!\n\n但是,我们还需要一点点操作。此设备的配置与远程数据库不兼容。我们需要再次从远程数据库获取。我们现在应该再次从远程获取吗?\n\n___注意:在更改配置并再次获取数据库之前,我们无法进行同步。___\n___注意2:chunks 是完全不可变的,我们只能获取元数据和差异",
|
|
23814
24015
|
"zh-tw": "你可能已經知道,Self-hosted LiveSync 變更了預設行為與資料庫結構。\n\n值得慶幸的是,在你的努力下,遠端資料庫似乎已經完成遷移。恭喜!\n\n不過,還需要再多做一點。此裝置的設定與遠端資料庫不相容,我們需要再次從遠端資料庫抓取。現在要再次從遠端抓取嗎?\n\n___注意:在變更設定並再次抓取資料庫之前,我們無法進行同步。___\n___注意 2:chunks 完全不可變,我們只需要抓取中繼資料與差異部分。___"
|
|
23815
24016
|
},
|
|
23816
|
-
"moduleMigration.msgInitialSetup": {
|
|
23817
|
-
def: "Your device has **not been set up yet**. Let me guide you through the setup process.\n\nPlease keep in mind that every dialogue content can be copied to the clipboard. If you need to refer to it later, you can paste it into a note in Obsidian. You can also translate it into your language using a translation tool.\n\nFirst, do you have **Setup URI**?\n\nNote: If you do not know what it is, please refer to the [documentation](${URI_DOC}).",
|
|
23818
|
-
es: "Tu dispositivo **aún no ha sido configurado**. Permíteme guiarte a través del proceso de configuración.\n\nTen en cuenta que todo el contenido del diálogo se puede copiar al portapapeles. Si necesitas consultarlo más tarde, puedes pegarlo en una nota en Obsidian. También puedes traducirlo a tu idioma utilizando una herramienta de traducción.\n\nPrimero, ¿tienes **URI de configuración**?\n\nNota: Si no sabes qué es, consulta la [documentación](${URI_DOC}).",
|
|
23819
|
-
fr: "Votre appareil n'a **pas encore été configuré**. Laissez-moi vous guider dans le processus de configuration.\n\nVeuillez noter que chaque contenu de boîte de dialogue peut être copié dans le presse-papiers. Si vous souhaitez vous y référer plus tard, vous pouvez le coller dans une note d'Obsidian. Vous pouvez également le traduire dans votre langue via un outil de traduction.\n\nTout d'abord, disposez-vous d'une **URI de configuration** ?\n\nNote : Si vous ne savez pas ce que c'est, consultez la [documentation](${URI_DOC}).",
|
|
23820
|
-
he: "המכשיר שלך **טרם הוגדר**. אנחנו כאן לעזור לך בתהליך ההגדרה.\n\nשים לב שניתן להעתיק את תוכן כל דיאלוג ללוח. אם צריך לחזור אליו מאוחר יותר, ניתן להדביק אותו כפתק ב-Obsidian. ניתן גם לתרגם לשפתך בעזרת כלי תרגום.\n\nראשית, האם יש לך **Setup URI**?\n\nהערה: אם אינך יודע מהו, אנא עיין ב[תיעוד](${URI_DOC}).",
|
|
23821
|
-
ja: "このデバイスは**まだセットアップされていません**。セットアッププロセスをご案内します。\n\nすべてのダイアログの内容はクリップボードにコピーできます。後で参照する必要があれば、Obsidianのノートに貼り付けてください。翻訳ツールを使ってお使いの言語に翻訳することもできます。\n\nまず、**セットアップURI**をお持ちですか?\n\n注意: それが何か分からない場合は、[documentation](${URI_DOC})を参照してください。",
|
|
23822
|
-
ko: "이 기기는 **아직 초기 설정이 완료되지 않았습니다**. 지금부터 설정 과정을 안내해 드리겠습니다.\n\n모든 대화 내용은 클립보드에 복사할 수 있습니다. 나중에 참고하려면 Obsidian 노트에 붙여넣거나 번역 도구를 활용해 번역하셔도 됩니다.\n\n먼저, **Setup URI**를 가지고 계신가요?\n\n참고: Setup URI가 무엇인지 잘 모르시겠다면 [문서](${URI_DOC})를 참고해 주세요.",
|
|
23823
|
-
ru: "Ваше устройство ещё не настроено. У вас есть Setup URI?",
|
|
23824
|
-
zh: "您的设备**尚未设置**。让我引导您完成设置过程。\n\n请记住,每个对话框内容都可以复制到剪贴板。如果以后需要参考,可以将其粘贴到 Obsidian 的笔记中。您也可以使用翻译工具将其翻译成您的语言。\n\n首先,您有**设置 URI** 吗?\n\n注意:如果您不知道这是什么,请参阅[文档](${URI_DOC})",
|
|
23825
|
-
"zh-tw": "你的裝置**尚未完成設定**。讓我引導你完成設定流程。\n\n請記得,每個對話框的內容都可以複製到剪貼簿。如果日後需要參考,可以貼到 Obsidian 的筆記中,也可以用翻譯工具翻成你的語言。\n\n首先,你有 **Setup URI** 嗎?\n\n注意:如果你不知道那是什麼,請參閱[說明文件](${URI_DOC})。"
|
|
23826
|
-
},
|
|
23827
|
-
"moduleMigration.msgRecommendSetupUri": {
|
|
23828
|
-
def: "We strongly recommend that you generate a set-up URI and use it.\nIf you do not have knowledge about it, please refer to the [documentation](${URI_DOC}) (Sorry again, but it is important).\n\nHow do you want to set it up manually?",
|
|
23829
|
-
es: "Te recomendamos encarecidamente que generes una URI de configuración y la utilices.\nSi no tienes conocimientos al respecto, consulta la [documentación](${URI_DOC}) (Lo siento de nuevo, pero es importante).\n\n¿Cómo quieres configurarlo manualmente?",
|
|
23830
|
-
fr: "Nous recommandons vivement de générer une URI de configuration et de l'utiliser.\nSi vous ne connaissez pas, veuillez consulter la [documentation](${URI_DOC}) (Désolé encore, mais c'est important).\n\nComment souhaitez-vous effectuer la configuration manuellement ?",
|
|
23831
|
-
he: "אנו ממליצים בחום לייצר Setup URI ולהשתמש בו.\nאם אין לך ידע בנושא, אנא עיין ב[תיעוד](${URI_DOC}) (מתנצלים שוב, אך זה חשוב).\n\nכיצד ברצונך להגדיר ידנית?",
|
|
23832
|
-
ja: "セットアップURIを生成して使用することを強くお勧めします。\nこれについて知識がない場合は、[documentation](${URI_DOC})を参照してください(重要です)。\n\n手動でセットアップしますか?",
|
|
23833
|
-
ko: "Setup URI를 생성해 사용하는 것을 강력히 권장합니다.\nSetup URI가 무엇인지 잘 모르시겠다면 [문서](${URI_DOC})를 참고해 주세요. 중요한 내용이니 꼭 확인하시기 바랍니다.\n\n직접 수동 설정을 진행하시겠습니까?",
|
|
23834
|
-
ru: "Мы рекомендуем сгенерировать Setup URI.",
|
|
23835
|
-
zh: "我们强烈建议您生成一个设置 URI 并使用它。\n如果您对此不了解,请参阅[文档](${URI_DOC})(再次抱歉,但这很重要)。\n\n您想如何手动设置?",
|
|
23836
|
-
"zh-tw": "我們強烈建議你產生 Setup URI 並使用它。\n如果你對此不熟悉,請參閱[說明文件](${URI_DOC})(再次抱歉,但這很重要)。\n\n你想要如何手動設定?"
|
|
23837
|
-
},
|
|
23838
24017
|
"moduleMigration.msgSinceV02321": {
|
|
23839
24018
|
def: "Since v0.23.21, the self-hosted LiveSync has changed the default behaviour and database structure. The following changes have been made:\n\n1. **Case sensitivity of filenames**\n The handling of filenames is now case-insensitive. This is a beneficial change for most platforms, other than Linux and iOS, which do not manage filename case sensitivity effectively.\n (On These, a warning will be displayed for files with the same name but different cases).\n\n2. **Revision handling of the chunks**\n Chunks are immutable, which allows their revisions to be fixed. This change will enhance the performance of file saving.\n\n___However, to enable either of these changes, both remote and local databases need to be rebuilt. This process takes a few minutes, and we recommend doing it when you have ample time.___\n\n- If you wish to maintain the previous behaviour, you can skip this process by using `${KEEP}`.\n- If you do not have enough time, please choose `${DISMISS}`. You will be prompted again later.\n- If you have rebuilt the database on another device, please select `${DISMISS}` and try synchronizing again. Since a difference has been detected, you will be prompted again.",
|
|
23840
24019
|
es: "Desde la versión v0.23.21, Self-hosted LiveSync ha cambiado el comportamiento predeterminado y la estructura de la base de datos. Se han realizado los siguientes cambios:\n\n1. **Sensibilidad a mayúsculas de los nombres de archivo**\n El manejo de los nombres de archivo ahora no distingue entre mayúsculas y minúsculas. Este cambio es beneficioso para la mayoría de las plataformas, excepto Linux y iOS, que no gestionan efectivamente la sensibilidad a mayúsculas de los nombres de archivo.\n (En estos, se mostrará una advertencia para archivos con el mismo nombre pero diferentes mayúsculas).\n\n2. **Manejo de revisiones de los fragmentos**\n Los fragmentos son inmutables, lo que permite que sus revisiones sean fijas. Este cambio mejorará el rendimiento al guardar archivos.\n\n___Sin embargo, para habilitar cualquiera de estos cambios, es necesario reconstruir tanto las bases de datos remota como la local. Este proceso toma unos minutos, y recomendamos hacerlo cuando tengas tiempo suficiente.___\n\n- Si deseas mantener el comportamiento anterior, puedes omitir este proceso usando `${KEEP}`.\n- Si no tienes suficiente tiempo, por favor elige `${DISMISS}`. Se te pedirá nuevamente más tarde.\n- Si has reconstruido la base de datos en otro dispositivo, selecciona `${DISMISS}` e intenta sincronizar nuevamente. Dado que se ha detectado una diferencia, se te solicitará nuevamente.",
|
|
@@ -23901,17 +24080,6 @@ var allMessages = {
|
|
|
23901
24080
|
zh: "仅启用 #2",
|
|
23902
24081
|
"zh-tw": "僅啟用"
|
|
23903
24082
|
},
|
|
23904
|
-
"moduleMigration.optionHaveSetupUri": {
|
|
23905
|
-
def: "Yes, I have",
|
|
23906
|
-
es: "Sí, tengo",
|
|
23907
|
-
fr: "Oui, j'en ai une",
|
|
23908
|
-
he: "כן, יש לי",
|
|
23909
|
-
ja: "はい、持っています",
|
|
23910
|
-
ko: "예, 있습니다",
|
|
23911
|
-
ru: "Да, есть",
|
|
23912
|
-
zh: "是的,我有",
|
|
23913
|
-
"zh-tw": "有,我有"
|
|
23914
|
-
},
|
|
23915
24083
|
"moduleMigration.optionKeepPreviousBehaviour": {
|
|
23916
24084
|
def: "Keep previous behaviour",
|
|
23917
24085
|
es: "Mantener comportamiento anterior",
|
|
@@ -23923,17 +24091,6 @@ var allMessages = {
|
|
|
23923
24091
|
zh: "保持以前的行为",
|
|
23924
24092
|
"zh-tw": "保留先前的行為"
|
|
23925
24093
|
},
|
|
23926
|
-
"moduleMigration.optionManualSetup": {
|
|
23927
|
-
def: "Set it up all manually",
|
|
23928
|
-
es: "Configurarlo todo manualmente",
|
|
23929
|
-
fr: "Tout configurer manuellement",
|
|
23930
|
-
he: "הגדר הכל ידנית",
|
|
23931
|
-
ja: "すべて手動でセットアップ",
|
|
23932
|
-
ko: "모든 것을 수동으로 설정",
|
|
23933
|
-
ru: "Настроить всё вручную",
|
|
23934
|
-
zh: "全部手动设置",
|
|
23935
|
-
"zh-tw": "全部手動設定"
|
|
23936
|
-
},
|
|
23937
24094
|
"moduleMigration.optionNoAskAgain": {
|
|
23938
24095
|
def: "No, please ask again",
|
|
23939
24096
|
es: "No, por favor pregúntame de nuevo",
|
|
@@ -23945,50 +24102,6 @@ var allMessages = {
|
|
|
23945
24102
|
zh: "不,请稍后再次询问",
|
|
23946
24103
|
"zh-tw": "不,請稍後再問我"
|
|
23947
24104
|
},
|
|
23948
|
-
"moduleMigration.optionNoSetupUri": {
|
|
23949
|
-
def: "No, I do not have",
|
|
23950
|
-
es: "No, no tengo",
|
|
23951
|
-
fr: "Non, je n'en ai pas",
|
|
23952
|
-
he: "לא, אין לי",
|
|
23953
|
-
ja: "いいえ、持っていません",
|
|
23954
|
-
ko: "아니요, 없습니다",
|
|
23955
|
-
ru: "Нет, нет",
|
|
23956
|
-
zh: "不,我没有",
|
|
23957
|
-
"zh-tw": "沒有,我沒有"
|
|
23958
|
-
},
|
|
23959
|
-
"moduleMigration.optionRemindNextLaunch": {
|
|
23960
|
-
def: "Remind me at the next launch",
|
|
23961
|
-
es: "Recordármelo en el próximo inicio",
|
|
23962
|
-
fr: "Me rappeler au prochain lancement",
|
|
23963
|
-
he: "הזכר לי בהפעלה הבאה",
|
|
23964
|
-
ja: "次回起動時にリマインド",
|
|
23965
|
-
ko: "다음 시작 시 알림",
|
|
23966
|
-
ru: "Напомнить при следующем запуске",
|
|
23967
|
-
zh: "下次启动时提醒我",
|
|
23968
|
-
"zh-tw": "下次啟動時提醒我"
|
|
23969
|
-
},
|
|
23970
|
-
"moduleMigration.optionSetupViaP2P": {
|
|
23971
|
-
def: "Use P2P Sync to set up",
|
|
23972
|
-
es: "Usar Sincronización P2P para configurarlo",
|
|
23973
|
-
fr: "Utiliser Sync P2P pour configurer",
|
|
23974
|
-
he: "השתמש ב-%{short_p2p_sync} להגדרה",
|
|
23975
|
-
ja: "P2P Sync (試験機能)を使ってセットアップ",
|
|
23976
|
-
ko: "P2P 동기화를 사용하여 설정",
|
|
23977
|
-
ru: "Использовать short_p2p_sync для настройки",
|
|
23978
|
-
zh: "Use P2P同步(实验性) to set up",
|
|
23979
|
-
"zh-tw": "使用「P2P 同步」進行設定"
|
|
23980
|
-
},
|
|
23981
|
-
"moduleMigration.optionSetupWizard": {
|
|
23982
|
-
def: "Take me into the setup wizard",
|
|
23983
|
-
es: "Llévame al asistente de configuración",
|
|
23984
|
-
fr: "Ouvrir l'assistant de configuration",
|
|
23985
|
-
he: "קח אותי לאשף ההגדרה",
|
|
23986
|
-
ja: "セットアップウィザードへ",
|
|
23987
|
-
ko: "설정 마법사로 안내",
|
|
23988
|
-
ru: "Перейти в мастер настройки",
|
|
23989
|
-
zh: "带我进入设置向导",
|
|
23990
|
-
"zh-tw": "帶我進入設定精靈"
|
|
23991
|
-
},
|
|
23992
24105
|
"moduleMigration.optionYesFetchAgain": {
|
|
23993
24106
|
def: "Yes, fetch again",
|
|
23994
24107
|
es: "Sí, obtener de nuevo",
|
|
@@ -24011,28 +24124,6 @@ var allMessages = {
|
|
|
24011
24124
|
zh: "大小写敏感性",
|
|
24012
24125
|
"zh-tw": "大小寫敏感性"
|
|
24013
24126
|
},
|
|
24014
|
-
"moduleMigration.titleRecommendSetupUri": {
|
|
24015
|
-
def: "Recommendation to use Setup URI",
|
|
24016
|
-
es: "Recomendación de usar un Setup URI",
|
|
24017
|
-
fr: "Recommandation d'utilisation de l'URI de configuration",
|
|
24018
|
-
he: "המלצה לשימוש ב-Setup URI",
|
|
24019
|
-
ja: "セットアップURIの使用を推奨",
|
|
24020
|
-
ko: "Setup URI 사용 권장",
|
|
24021
|
-
ru: "Рекомендация использовать Setup URI",
|
|
24022
|
-
zh: "推荐使用设置 URI",
|
|
24023
|
-
"zh-tw": "建議使用 Setup URI"
|
|
24024
|
-
},
|
|
24025
|
-
"moduleMigration.titleWelcome": {
|
|
24026
|
-
def: "Welcome to Self-hosted LiveSync",
|
|
24027
|
-
es: "Bienvenido a Self-hosted LiveSync",
|
|
24028
|
-
fr: "Bienvenue dans Self-hosted LiveSync",
|
|
24029
|
-
he: "ברוך הבא ל-Self-hosted LiveSync",
|
|
24030
|
-
ja: "Self-hosted LiveSyncへようこそ",
|
|
24031
|
-
ko: "Self-hosted LiveSync에 오신 것을 환영합니다",
|
|
24032
|
-
ru: "Добро пожаловать в Self-hosted LiveSync",
|
|
24033
|
-
zh: "欢迎使用 Self-hosted LiveSync",
|
|
24034
|
-
"zh-tw": "歡迎使用 Self-hosted LiveSync"
|
|
24035
|
-
},
|
|
24036
24127
|
"moduleObsidianMenu.replicate": {
|
|
24037
24128
|
def: "Replicate",
|
|
24038
24129
|
es: "Replicar",
|
|
@@ -24415,17 +24506,6 @@ var allMessages = {
|
|
|
24415
24506
|
zh: "我明白了并且已更新",
|
|
24416
24507
|
"zh-tw": "我知道了,且已更新。"
|
|
24417
24508
|
},
|
|
24418
|
-
"obsidianLiveSyncSettingTab.btnNext": {
|
|
24419
|
-
def: "Next",
|
|
24420
|
-
es: "Siguiente",
|
|
24421
|
-
fr: "Suivant",
|
|
24422
|
-
he: "הבא",
|
|
24423
|
-
ja: "次へ",
|
|
24424
|
-
ko: "다음",
|
|
24425
|
-
ru: "Далее",
|
|
24426
|
-
zh: "下一步",
|
|
24427
|
-
"zh-tw": "下一步"
|
|
24428
|
-
},
|
|
24429
24509
|
"obsidianLiveSyncSettingTab.btnStart": {
|
|
24430
24510
|
def: "Start",
|
|
24431
24511
|
es: "Iniciar",
|
|
@@ -24470,17 +24550,6 @@ var allMessages = {
|
|
|
24470
24550
|
zh: "获取",
|
|
24471
24551
|
"zh-tw": "抓取"
|
|
24472
24552
|
},
|
|
24473
|
-
"obsidianLiveSyncSettingTab.buttonNext": {
|
|
24474
|
-
def: "Next",
|
|
24475
|
-
es: "Siguiente",
|
|
24476
|
-
fr: "Suivant",
|
|
24477
|
-
he: "הבא",
|
|
24478
|
-
ja: "次へ",
|
|
24479
|
-
ko: "다음",
|
|
24480
|
-
ru: "Далее",
|
|
24481
|
-
zh: "下一步",
|
|
24482
|
-
"zh-tw": "下一步"
|
|
24483
|
-
},
|
|
24484
24553
|
"obsidianLiveSyncSettingTab.defaultLanguage": {
|
|
24485
24554
|
def: "Default",
|
|
24486
24555
|
es: "Predeterminado",
|
|
@@ -25166,17 +25235,6 @@ var allMessages = {
|
|
|
25166
25235
|
zh: "要从远端服务器获取配置吗?",
|
|
25167
25236
|
"zh-tw": "要從遠端伺服器抓取設定嗎?"
|
|
25168
25237
|
},
|
|
25169
|
-
"obsidianLiveSyncSettingTab.msgGenerateSetupURI": {
|
|
25170
|
-
def: "All done! Do you want to generate a setup URI to set up other devices?",
|
|
25171
|
-
es: "¡Todo listo! ¿Quieres generar un URI de configuración para configurar otros dispositivos?",
|
|
25172
|
-
fr: "Tout est prêt ! Voulez-vous générer une URI de configuration pour configurer d'autres appareils ?",
|
|
25173
|
-
he: "הכל מוכן! האם ברצונך לייצר Setup URI להגדרת מכשירים אחרים?",
|
|
25174
|
-
ja: "完了!他のデバイスをセットアップするためのセットアップURIを生成しますか?",
|
|
25175
|
-
ko: "모든 작업이 완료되었습니다! 다른 기기를 설정하기 위해 Setup URI를 생성하시겠습니까?",
|
|
25176
|
-
ru: "Всё готово! Вы хотите сгенерировать Setup URI для настройки других устройств?",
|
|
25177
|
-
zh: "全部完成!要生成设置 URI 以便配置其他设备吗?",
|
|
25178
|
-
"zh-tw": "全部完成!要產生 Setup URI 以便設定其他裝置嗎?"
|
|
25179
|
-
},
|
|
25180
25238
|
"obsidianLiveSyncSettingTab.msgIfConfigNotPersistent": {
|
|
25181
25239
|
def: "If the server configuration is not persistent (e.g., running on docker), the values here may change. Once you are able to connect, please update the settings in the server's local.ini.",
|
|
25182
25240
|
es: "Si la configuración del servidor no es persistente (por ejemplo, ejecutándose en docker), los valores aquí pueden cambiar. Una vez que puedas conectarte, por favor actualiza las configuraciones en el local.ini del servidor.",
|
|
@@ -25276,17 +25334,6 @@ var allMessages = {
|
|
|
25276
25334
|
zh: "需要重建数据库以应用更改。请选择应用更改的方法。\n\n<details>\n<summary>图例</summary>\n\n| 符号 | 含义 |\n|: ------ :| ------- |\n| ⇔ | 最新 |\n| ⇄ | 同步以平衡 |\n| ⇐,⇒ | 传输以覆盖 |\n| ⇠,⇢ | 从另一侧传输以覆盖 |\n\n</details>\n\n## ${OPTION_REBUILD_BOTH}\n概览:📄 ⇒¹ 💻 ⇒² 🛰️ ⇢ⁿ 💻 ⇄ⁿ⁺¹ 📄\n使用此设备的现有文件重建本地和远程数据库。\n这将导致其他设备被锁定,并且它们需要执行获取操作。\n## ${OPTION_FETCH}\n概览:📄 ⇄² 💻 ⇐¹ 🛰️ ⇔ 💻 ⇔ 📄\n初始化本地数据库并使用从远程数据库获取的数据重建它。\n这种情况包括您已经重建了远程数据库的情况。\n## ${OPTION_ONLY_SETTING}\n仅存储设置。**注意:这可能导致数据损坏**;通常需要重建数据库",
|
|
25277
25335
|
"zh-tw": "需要重建資料庫才能套用變更。請選擇套用變更的方式。\n\n<details>\n<summary>圖例</summary>\n\n| 符號 | 含意 |\n|: ------ :| ------- |\n| ⇔ | 已是最新 |\n| ⇄ | 同步以取得一致 |\n| ⇐,⇒ | 傳輸並覆寫 |\n| ⇠,⇢ | 從另一端傳輸並覆寫 |\n\n</details>\n\n## ${OPTION_REBUILD_BOTH}\n概覽: 📄 ⇒¹ 💻 ⇒² 🛰️ ⇢ⁿ 💻 ⇄ⁿ⁺¹ 📄\n以此裝置上現有的檔案重建本機與遠端資料庫。\n這會鎖定其他裝置,它們必須執行抓取。\n## ${OPTION_FETCH}\n概覽: 📄 ⇄² 💻 ⇐¹ 🛰️ ⇔ 💻 ⇔ 📄\n初始化本機資料庫,並以從遠端資料庫抓取的資料重建。\n這也涵蓋你已重建遠端資料庫的情況。\n## ${OPTION_ONLY_SETTING}\n僅儲存設定。**注意:這可能導致資料損毀**;通常仍需要重建資料庫。"
|
|
25278
25336
|
},
|
|
25279
|
-
"obsidianLiveSyncSettingTab.msgSelectAndApplyPreset": {
|
|
25280
|
-
def: "Please select and apply any preset item to complete the wizard.",
|
|
25281
|
-
es: "Por favor, selecciona y aplica cualquier elemento preestablecido para completar el asistente.",
|
|
25282
|
-
fr: "Veuillez sélectionner et appliquer un préréglage pour terminer l'assistant.",
|
|
25283
|
-
he: "אנא בחר והחל פריט קבוע מראש כלשהו להשלמת האשף.",
|
|
25284
|
-
ja: "ウィザードを完了するには、プリセット項目を選択して適用してください。",
|
|
25285
|
-
ko: "마법사를 완료하려면 프리셋 항목을 선택하고 적용해 주세요.",
|
|
25286
|
-
ru: "Выберите и примените любой пресет для завершения мастера.",
|
|
25287
|
-
zh: "请选择并应用任一预设项以完成向导。",
|
|
25288
|
-
"zh-tw": "請選擇並套用任一預設項目以完成精靈。"
|
|
25289
|
-
},
|
|
25290
25337
|
"obsidianLiveSyncSettingTab.msgSetCorsCredentials": {
|
|
25291
25338
|
def: "Set cors.credentials",
|
|
25292
25339
|
es: "Configurar cors.credentials",
|
|
@@ -25881,6 +25928,7 @@ var allMessages = {
|
|
|
25881
25928
|
zh: "活动远程服务器",
|
|
25882
25929
|
"zh-tw": "使用中的遠端伺服器"
|
|
25883
25930
|
},
|
|
25931
|
+
"obsidianLiveSyncSettingTab.titleAdvancedSettings": { def: "Advanced settings" },
|
|
25884
25932
|
"obsidianLiveSyncSettingTab.titleAppearance": {
|
|
25885
25933
|
def: "Appearance",
|
|
25886
25934
|
es: "Apariencia",
|
|
@@ -25903,17 +25951,6 @@ var allMessages = {
|
|
|
25903
25951
|
zh: "冲突处理",
|
|
25904
25952
|
"zh-tw": "衝突處理"
|
|
25905
25953
|
},
|
|
25906
|
-
"obsidianLiveSyncSettingTab.titleCongratulations": {
|
|
25907
|
-
def: "Congratulations!",
|
|
25908
|
-
es: "¡Felicidades!",
|
|
25909
|
-
fr: "Félicitations !",
|
|
25910
|
-
he: "מזל טוב!",
|
|
25911
|
-
ja: "おめでとうございます!",
|
|
25912
|
-
ko: "축하합니다!",
|
|
25913
|
-
ru: "Поздравляем!",
|
|
25914
|
-
zh: "恭喜!",
|
|
25915
|
-
"zh-tw": "恭喜!"
|
|
25916
|
-
},
|
|
25917
25954
|
"obsidianLiveSyncSettingTab.titleCouchDB": {
|
|
25918
25955
|
def: "CouchDB",
|
|
25919
25956
|
es: "Servidor CouchDB",
|
|
@@ -25969,6 +26006,8 @@ var allMessages = {
|
|
|
25969
26006
|
zh: "启用额外和高级功能",
|
|
25970
26007
|
"zh-tw": "啟用額外與進階功能"
|
|
25971
26008
|
},
|
|
26009
|
+
"obsidianLiveSyncSettingTab.titleExtraFeaturesGroup": { def: "Extra features" },
|
|
26010
|
+
"obsidianLiveSyncSettingTab.titleExtraMenus": { def: "Extra menus" },
|
|
25972
26011
|
"obsidianLiveSyncSettingTab.titleFetchConfig": {
|
|
25973
26012
|
def: "Fetch Config",
|
|
25974
26013
|
es: "Obtener configuración",
|
|
@@ -26002,6 +26041,8 @@ var allMessages = {
|
|
|
26002
26041
|
zh: "获取设置",
|
|
26003
26042
|
"zh-tw": "抓取設定"
|
|
26004
26043
|
},
|
|
26044
|
+
"obsidianLiveSyncSettingTab.titleHelpAndInformation": { def: "Help and information" },
|
|
26045
|
+
"obsidianLiveSyncSettingTab.titleHelpAndTroubleshooting": { def: "Help and troubleshooting" },
|
|
26005
26046
|
"obsidianLiveSyncSettingTab.titleHiddenFiles": {
|
|
26006
26047
|
def: "Hidden Files",
|
|
26007
26048
|
es: "Archivos ocultos",
|
|
@@ -26024,6 +26065,7 @@ var allMessages = {
|
|
|
26024
26065
|
zh: "日志",
|
|
26025
26066
|
"zh-tw": "記錄"
|
|
26026
26067
|
},
|
|
26068
|
+
"obsidianLiveSyncSettingTab.titleMaintenanceAndRecovery": { def: "Maintenance and recovery" },
|
|
26027
26069
|
"obsidianLiveSyncSettingTab.titleMinioS3R2": {
|
|
26028
26070
|
def: "Minio,S3,R2",
|
|
26029
26071
|
es: "MinIO, S3, R2",
|
|
@@ -26113,7 +26155,7 @@ var allMessages = {
|
|
|
26113
26155
|
"zh-tw": "重設"
|
|
26114
26156
|
},
|
|
26115
26157
|
"obsidianLiveSyncSettingTab.titleSetupOtherDevices": {
|
|
26116
|
-
def: "
|
|
26158
|
+
def: "Set up other devices",
|
|
26117
26159
|
es: "Para configurar otros dispositivos",
|
|
26118
26160
|
fr: "Pour configurer d'autres appareils",
|
|
26119
26161
|
he: "להגדרת מכשירים אחרים",
|
|
@@ -26123,6 +26165,7 @@ var allMessages = {
|
|
|
26123
26165
|
zh: "设置其他设备",
|
|
26124
26166
|
"zh-tw": "設定其他裝置"
|
|
26125
26167
|
},
|
|
26168
|
+
"obsidianLiveSyncSettingTab.titleSynchronisation": { def: "Synchronisation" },
|
|
26126
26169
|
"obsidianLiveSyncSettingTab.titleSynchronizationMethod": {
|
|
26127
26170
|
def: "Synchronization Method",
|
|
26128
26171
|
es: "Método de sincronización",
|
|
@@ -27529,7 +27572,7 @@ var allMessages = {
|
|
|
27529
27572
|
"zh-tw": "複寫因某個模組失敗而取消"
|
|
27530
27573
|
},
|
|
27531
27574
|
"Replicator.Message.VersionUpFlash": {
|
|
27532
|
-
def: "
|
|
27575
|
+
def: "Remote synchronisation is paused for compatibility review. Run the 'Review why synchronisation is paused' command for details and available actions.",
|
|
27533
27576
|
es: "Se ha detectado una actualización. Abre el diálogo de ajustes y consulta el registro de cambios. La replicación se ha cancelado.",
|
|
27534
27577
|
fr: "Une mise à jour a été détectée. Veuillez ouvrir la boîte de dialogue des paramètres et consulter le journal des modifications. La réplication a été annulée.",
|
|
27535
27578
|
he: "זוהה עדכון. אנא פתח את דיאלוג ההגדרות ובדוק את יומן השינויים. השכפול בוטל.",
|
|
@@ -31162,6 +31205,28 @@ var allMessages = {
|
|
|
31162
31205
|
zh: "覆盖",
|
|
31163
31206
|
"zh-tw": "覆寫"
|
|
31164
31207
|
},
|
|
31208
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.ApplyWithoutInitialisation": { def: "Apply without Initialisation" },
|
|
31209
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.Back": { def: "Review another way to apply these settings" },
|
|
31210
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.BypassGuidance": { def: "Applying these settings alone can make this device incompatible with its existing synchronisation data. Use this only when you have confirmed that reconstruction is unnecessary." },
|
|
31211
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.BypassTitle": { def: "Apply Settings without Initialisation?" },
|
|
31212
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.ContinueFetch": { def: "Continue with Fetch" },
|
|
31213
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.FetchOption": { def: "Reset Synchronisation on This Device" },
|
|
31214
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.FetchOptionDesc": { def: "After restarting, rebuild this device's local database from the current remote synchronisation data. Files in the Vault will then be reconciled with that data." },
|
|
31215
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.FetchOptionP2PDesc": { def: "After restarting, select an online source device. This device's local LiveSync database will be rebuilt from that source." },
|
|
31216
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.Guidance": { def: "These setting changes alter how synchronisation data is interpreted. Apply them together with an initialisation operation after restart." },
|
|
31217
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.KeepEditing": { def: "Keep Editing" },
|
|
31218
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.ProceedFetch": { def: "Restart and Fetch Synchronisation Data" },
|
|
31219
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.ProceedFetchP2P": { def: "Restart and Select a Source Device" },
|
|
31220
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.ProceedRebuild": { def: "Restart and Overwrite Server Data" },
|
|
31221
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.ProceedRebuildP2P": { def: "Restart and Prepare This Device" },
|
|
31222
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.Question": { def: "Which existing data should be used after restart?" },
|
|
31223
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.RebuildOption": { def: "Overwrite Server Data with This Device's Files" },
|
|
31224
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.RebuildOptionDesc": { def: "Rebuild the local and remote databases from the files currently in this Vault. Other synchronising devices must reset their local synchronisation afterwards." },
|
|
31225
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.RebuildOptionP2P": { def: "Prepare This Device from This Vault" },
|
|
31226
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.RebuildOptionP2PDesc": { def: "Rebuild this device's local LiveSync database from the files currently in this Vault. This does not overwrite another device." },
|
|
31227
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.RemoteVerificationGuidance": { def: "The configured remote could not be verified with the current credentials and encryption settings. Continuing may make the Fetch fail after restart." },
|
|
31228
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.RemoteVerificationTitle": { def: "Remote Synchronisation Data Could Not Be Verified" },
|
|
31229
|
+
"Ui.SetupWizard.ApplySettingsInitialisation.Title": { def: "Apply Settings and Reinitialise Synchronisation" },
|
|
31165
31230
|
"Ui.SetupWizard.Common.Back": {
|
|
31166
31231
|
def: "No, please take me back",
|
|
31167
31232
|
es: "No, volver atrás",
|
|
@@ -32134,6 +32199,17 @@ var liveSyncProvisionalEnglishMessages = {
|
|
|
32134
32199
|
"Learn more about P2P connections": "Learn more about P2P connections",
|
|
32135
32200
|
"Learn more about signalling and TURN": "Learn more about signalling and TURN",
|
|
32136
32201
|
"TURN relays the encrypted WebRTC connection only when a direct path cannot be established. A TURN provider cannot read encrypted Vault contents, but it can observe connection metadata and traffic volume. Use a provider you trust.": "TURN relays the encrypted WebRTC connection only when a direct path cannot be established. A TURN provider cannot read encrypted Vault contents, but it can observe connection metadata and traffic volume. Use a provider you trust.",
|
|
32202
|
+
"Connection compatibility": "Connection compatibility",
|
|
32203
|
+
"P2P message size": "P2P message size",
|
|
32204
|
+
Standard: "Standard",
|
|
32205
|
+
Reduced: "Reduced",
|
|
32206
|
+
Conservative: "Conservative",
|
|
32207
|
+
"Maximum compatibility": "Maximum compatibility",
|
|
32208
|
+
"Smaller messages can improve compatibility on paths which fragment or drop larger WebRTC messages. This setting limits outgoing P2P messages, so use a compatible profile on each sending device when required.": "Smaller messages can improve compatibility on paths which fragment or drop larger WebRTC messages. This setting limits outgoing P2P messages, so use a compatible profile on each sending device when required.",
|
|
32209
|
+
"Connection path": "Connection path",
|
|
32210
|
+
"TURN relay only": "TURN relay only",
|
|
32211
|
+
"TURN relay only is available when at least one valid TURN server URL is configured under Advanced Settings.": "TURN relay only is available when at least one valid TURN server URL is configured under Advanced Settings.",
|
|
32212
|
+
"TURN relay only requires at least one valid TURN server URL. Connection path has been restored to Automatic.": "TURN relay only requires at least one valid TURN server URL. Connection path has been restored to Automatic.",
|
|
32137
32213
|
"Announce changes": "Announce changes",
|
|
32138
32214
|
"Announce changes automatically after connecting": "Announce changes automatically after connecting",
|
|
32139
32215
|
"When enabled, this device notifies connected peers after a local change. The notification contains no Vault data; a peer which follows this device then fetches the change through the encrypted P2P connection.": "When enabled, this device notifies connected peers after a local change. The notification contains no Vault data; a peer which follows this device then fetches the change through the encrypted P2P connection.",
|
|
@@ -32309,6 +32385,10 @@ function $t(message, lang) {
|
|
|
32309
32385
|
if (lang !== void 0) return _getMessage(message, lang);
|
|
32310
32386
|
return getMessage(message);
|
|
32311
32387
|
}
|
|
32388
|
+
function translateIfAvailable(message, lang) {
|
|
32389
|
+
if (message.trim() == "" || !isLiveSyncMessageKey(message) && !isCommonlibMessageKey(message)) return message;
|
|
32390
|
+
return $t(message, lang);
|
|
32391
|
+
}
|
|
32312
32392
|
function isCommonlibMessageKey(key) {
|
|
32313
32393
|
return key in commonlibEnglishMessages;
|
|
32314
32394
|
}
|
|
@@ -35156,6 +35236,17 @@ var ReplicateResultProcessor = class {
|
|
|
35156
35236
|
}
|
|
35157
35237
|
};
|
|
35158
35238
|
//#endregion
|
|
35239
|
+
//#region ../../common/compatibilitySettings.ts
|
|
35240
|
+
/**
|
|
35241
|
+
* Returns whether persisted settings select the legacy PouchDB IndexedDB adapter.
|
|
35242
|
+
*
|
|
35243
|
+
* New local databases use IDB. Existing devices must retain this operative value until their local database has
|
|
35244
|
+
* been explicitly migrated, so compatibility code must not treat the setting as inert.
|
|
35245
|
+
*/
|
|
35246
|
+
function usesLegacyIndexedDBAdapter(settings) {
|
|
35247
|
+
return settings.useIndexedDBAdapter;
|
|
35248
|
+
}
|
|
35249
|
+
//#endregion
|
|
35159
35250
|
//#region ../../modules/core/ModuleReplicator.ts
|
|
35160
35251
|
function isOnlineAndCanReplicate(errorManager, host, showMessage) {
|
|
35161
35252
|
const errorMessage = "Network is offline";
|
|
@@ -35234,10 +35325,12 @@ var ModuleReplicator = class extends AbstractModule {
|
|
|
35234
35325
|
return true;
|
|
35235
35326
|
}
|
|
35236
35327
|
/**
|
|
35237
|
-
* Reconciles
|
|
35238
|
-
*
|
|
35239
|
-
*
|
|
35240
|
-
*
|
|
35328
|
+
* Reconciles an IndexedDB-backed local database after replication reports that the remote was cleaned.
|
|
35329
|
+
*
|
|
35330
|
+
* The remote milestone remains a supported compatibility signal. The user can either fetch the remote
|
|
35331
|
+
* database again, or purge unreferenced local chunks before accepting this device again.
|
|
35332
|
+
*
|
|
35333
|
+
* @param showMessage Whether to show the recovery choices as user-facing notices.
|
|
35241
35334
|
*/
|
|
35242
35335
|
async cleaned(showMessage) {
|
|
35243
35336
|
Logger(`The remote database has been cleaned.`, showMessage ? 64 : 32);
|
|
@@ -35287,7 +35380,7 @@ Even if you choose to clean up, you will see this option again if you exit Obsid
|
|
|
35287
35380
|
return false;
|
|
35288
35381
|
}
|
|
35289
35382
|
if (activeReplicator.tweakSettingsMismatched && activeReplicator.preferredTweakValue) await this.services.tweakValue.askResolvingMismatched(activeReplicator.preferredTweakValue);
|
|
35290
|
-
else if (activeReplicator.remoteLockedAndDeviceNotAccepted) if (activeReplicator.remoteCleaned && this.settings
|
|
35383
|
+
else if (activeReplicator.remoteLockedAndDeviceNotAccepted) if (activeReplicator.remoteCleaned && usesLegacyIndexedDBAdapter(this.settings)) await this.cleaned(showMessage);
|
|
35291
35384
|
else {
|
|
35292
35385
|
const message = $msg("Replicator.Dialogue.Locked.Message");
|
|
35293
35386
|
const CHOICE_FETCH = $msg("Replicator.Dialogue.Locked.Action.Fetch");
|
|
@@ -54643,6 +54736,15 @@ var ModuleConflictResolver = class extends AbstractModule {
|
|
|
54643
54736
|
};
|
|
54644
54737
|
//#endregion
|
|
54645
54738
|
//#region ../../modules/coreFeatures/ModuleResolveMismatchedTweaks.ts
|
|
54739
|
+
/**
|
|
54740
|
+
* Localised counterpart of Commonlib's `confName()`, which takes no translator.
|
|
54741
|
+
* Same shape: label plus status suffix, and an empty string for an unknown key.
|
|
54742
|
+
*/
|
|
54743
|
+
function localisedConfName(key) {
|
|
54744
|
+
const info = configurationNames[key];
|
|
54745
|
+
if (!info) return "";
|
|
54746
|
+
return `${translateIfAvailable(info.name)}${statusDisplay(info.status)}`;
|
|
54747
|
+
}
|
|
54646
54748
|
function valueToString(value) {
|
|
54647
54749
|
if (typeof value === "boolean") return value ? "true" : "false";
|
|
54648
54750
|
if (typeof value === "object") return JSON.stringify(value);
|
|
@@ -54730,7 +54832,7 @@ var ModuleResolvingMismatchedTweaks = class extends AbstractModule {
|
|
|
54730
54832
|
}
|
|
54731
54833
|
if (CompatibleButLossyChanges.indexOf(key) !== -1) rebuildRecommended = true;
|
|
54732
54834
|
tableRows.push($msg("TweakMismatchResolve.Table.Row", {
|
|
54733
|
-
name:
|
|
54835
|
+
name: localisedConfName(key),
|
|
54734
54836
|
self: valueToString(valueMine),
|
|
54735
54837
|
remote: valueToString(valuePreferred)
|
|
54736
54838
|
}));
|
|
@@ -54860,7 +54962,7 @@ var ModuleResolvingMismatchedTweaks = class extends AbstractModule {
|
|
|
54860
54962
|
if (CompatibleButLossyChanges.indexOf(key) !== -1) rebuildRecommended = true;
|
|
54861
54963
|
} else continue;
|
|
54862
54964
|
tableRows.push($msg("TweakMismatchResolve.Table.Row", {
|
|
54863
|
-
name:
|
|
54965
|
+
name: localisedConfName(key),
|
|
54864
54966
|
self: currentValueForDisplay,
|
|
54865
54967
|
remote: remoteValueForDisplay
|
|
54866
54968
|
}));
|
|
@@ -54919,8 +55021,8 @@ var ModuleResolvingMismatchedTweaks = class extends AbstractModule {
|
|
|
54919
55021
|
};
|
|
54920
55022
|
//#endregion
|
|
54921
55023
|
//#region ../../../node_modules/@vrtmrz/livesync-commonlib/dist/common/coreEnvVars.js
|
|
54922
|
-
var manifestVersion = "1.0.
|
|
54923
|
-
var packageVersion = "1.0.
|
|
55024
|
+
var manifestVersion = "1.0.21";
|
|
55025
|
+
var packageVersion = "1.0.21";
|
|
54924
55026
|
//#endregion
|
|
54925
55027
|
//#region ../../modules/main/ModuleLiveSyncMain.ts
|
|
54926
55028
|
var ModuleLiveSyncMain = class extends AbstractModule {
|
|
@@ -55278,24 +55380,21 @@ var ModuleBasicMenu = class extends AbstractModule {
|
|
|
55278
55380
|
async function prepareDatabaseForUse(host, log, errorManager, showingNotice = false, reopenDatabase = true, ignoreSuspending = false) {
|
|
55279
55381
|
const appLifecycle = host.services.appLifecycle;
|
|
55280
55382
|
appLifecycle.resetIsReady();
|
|
55281
|
-
if (
|
|
55383
|
+
if (reopenDatabase && !await host.services.database.openDatabase({
|
|
55282
55384
|
databaseEvents: host.services.databaseEvents,
|
|
55283
55385
|
replicator: host.services.replicator
|
|
55284
|
-
}))
|
|
55285
|
-
|
|
55286
|
-
|
|
55287
|
-
|
|
55288
|
-
|
|
55289
|
-
|
|
55290
|
-
}
|
|
55291
|
-
errorManager.clearError(ERR_INITIALISATION_FAILED);
|
|
55292
|
-
appLifecycle.markIsReady();
|
|
55293
|
-
await host.services.fileProcessing.commitPendingFileEvents();
|
|
55294
|
-
return true;
|
|
55295
|
-
} else {
|
|
55296
|
-
appLifecycle.resetIsReady();
|
|
55386
|
+
})) return false;
|
|
55387
|
+
if (!host.services.database.isDatabaseReady()) return false;
|
|
55388
|
+
if (!await host.services.vault.scanVault(showingNotice, ignoreSuspending)) return false;
|
|
55389
|
+
const ERR_INITIALISATION_FAILED = `Initializing database has been failed on some module!`;
|
|
55390
|
+
if (!await host.services.databaseEvents.onDatabaseInitialised(showingNotice)) {
|
|
55391
|
+
errorManager.showError(ERR_INITIALISATION_FAILED, 64);
|
|
55297
55392
|
return false;
|
|
55298
55393
|
}
|
|
55394
|
+
errorManager.clearError(ERR_INITIALISATION_FAILED);
|
|
55395
|
+
if (!await host.services.fileProcessing.commitPendingFileEvents()) return false;
|
|
55396
|
+
appLifecycle.markIsReady();
|
|
55397
|
+
return true;
|
|
55299
55398
|
}
|
|
55300
55399
|
function usePrepareDatabaseForUse(host) {
|
|
55301
55400
|
const log = createInstanceLogFunction("SF:prepareDatabaseForUse", host.services.API);
|
|
@@ -55845,6 +55944,7 @@ var ServiceRebuilder = class extends ServiceModuleBase {
|
|
|
55845
55944
|
replication;
|
|
55846
55945
|
database;
|
|
55847
55946
|
fileHandler;
|
|
55947
|
+
fileProcessing;
|
|
55848
55948
|
control;
|
|
55849
55949
|
constructor(services) {
|
|
55850
55950
|
super(services);
|
|
@@ -55861,6 +55961,7 @@ var ServiceRebuilder = class extends ServiceModuleBase {
|
|
|
55861
55961
|
this.replication = services.replication;
|
|
55862
55962
|
this.database = services.database;
|
|
55863
55963
|
this.fileHandler = services.fileHandler;
|
|
55964
|
+
this.fileProcessing = services.fileProcessing;
|
|
55864
55965
|
this.control = services.control;
|
|
55865
55966
|
services.database.onDatabaseReset.addHandler(this._onResetLocalDatabase.bind(this));
|
|
55866
55967
|
services.setting.suspendAllSync.addHandler(this._allSuspendAllSync.bind(this));
|
|
@@ -55903,6 +56004,7 @@ Please enable them from the settings screen after setup is complete.`, ["OK"]);
|
|
|
55903
56004
|
await this.informOptionalFeatures();
|
|
55904
56005
|
}
|
|
55905
56006
|
async performRebuildEverything() {
|
|
56007
|
+
this.appLifecycle.resetIsReady();
|
|
55906
56008
|
await this.setting.suspendExtraSync();
|
|
55907
56009
|
await this.setting.applyPartial({
|
|
55908
56010
|
isConfigured: true,
|
|
@@ -55911,16 +56013,20 @@ Please enable them from the settings screen after setup is complete.`, ["OK"]);
|
|
|
55911
56013
|
await this.control.applySettings();
|
|
55912
56014
|
await this.resetLocalDatabase();
|
|
55913
56015
|
await delay$1(1e3);
|
|
55914
|
-
await this.
|
|
55915
|
-
if (this.setting.currentSettings().remoteType === REMOTE_P2P)
|
|
56016
|
+
await this.prepareLocalDatabaseForRebuild();
|
|
56017
|
+
if (this.setting.currentSettings().remoteType === REMOTE_P2P) {
|
|
56018
|
+
if (!await this.completePreparedRebuild()) throw new Error("The local P2P rebuild could not be finalised.");
|
|
56019
|
+
return;
|
|
56020
|
+
}
|
|
55916
56021
|
await this.replication.markLocked();
|
|
55917
56022
|
await this._tryResetRemoteDatabase();
|
|
55918
56023
|
await this.replication.markLocked();
|
|
55919
56024
|
await delay$1(500);
|
|
55920
56025
|
await delay$1(1e3);
|
|
55921
|
-
await this.replication.
|
|
56026
|
+
if (!await this.replication.replicateAllToRemoteForRebuild(true)) throw new Error("The first rebuild upload did not complete.");
|
|
55922
56027
|
await delay$1(1e3);
|
|
55923
|
-
await this.replication.
|
|
56028
|
+
if (!await this.replication.replicateAllToRemoteForRebuild(true)) throw new Error("The final rebuild upload did not complete.");
|
|
56029
|
+
if (!await this.completePreparedRebuild()) throw new Error("The rebuild could not be finalised.");
|
|
55924
56030
|
}
|
|
55925
56031
|
$rebuildEverything() {
|
|
55926
56032
|
return this.rebuildEverything();
|
|
@@ -55997,18 +56103,43 @@ Please enable them from the settings screen after setup is complete.`, ["OK"]);
|
|
|
55997
56103
|
});
|
|
55998
56104
|
await this.setting.saveSettingData();
|
|
55999
56105
|
}
|
|
56106
|
+
/**
|
|
56107
|
+
* Stage reflection resumption and perform the final reconciliation checks.
|
|
56108
|
+
*
|
|
56109
|
+
* File watching is resumed in memory before the final scan so that changes
|
|
56110
|
+
* made while the scan is running can enter the storage-event queue. This
|
|
56111
|
+
* phase deliberately does not persist the resumed settings. The owning
|
|
56112
|
+
* completion boundary persists them only after the scan, replication
|
|
56113
|
+
* pre-check, and current batch-wait release have succeeded.
|
|
56114
|
+
*
|
|
56115
|
+
* @param ignoreMinIO Whether to resume reflection for a MinIO remote.
|
|
56116
|
+
* @returns `true` when the applicable reconciliation checks succeeded.
|
|
56117
|
+
*/
|
|
56000
56118
|
async resumeReflectingDatabase(ignoreMinIO = false) {
|
|
56001
56119
|
const settings = this.setting.currentSettings();
|
|
56002
|
-
if (settings.doNotSuspendOnFetching) return;
|
|
56003
|
-
if (!ignoreMinIO && settings.remoteType == REMOTE_MINIO) return;
|
|
56120
|
+
if (settings.doNotSuspendOnFetching) return true;
|
|
56121
|
+
if (!ignoreMinIO && settings.remoteType == REMOTE_MINIO) return true;
|
|
56004
56122
|
this._log(`Database and storage reflection has been resumed!`, 64);
|
|
56005
56123
|
await this.setting.applyPartial({
|
|
56006
56124
|
suspendParseReplicationResult: false,
|
|
56007
56125
|
suspendFileWatching: false
|
|
56008
56126
|
});
|
|
56009
|
-
await this.vault.scanVault(true);
|
|
56010
|
-
await this.replication.onBeforeReplicate(false);
|
|
56011
|
-
|
|
56127
|
+
if (!await this.vault.scanVault(true)) return false;
|
|
56128
|
+
if (!await this.replication.onBeforeReplicate(false)) return false;
|
|
56129
|
+
return true;
|
|
56130
|
+
}
|
|
56131
|
+
async prepareLocalDatabaseForRebuild() {
|
|
56132
|
+
if (!this.database.isDatabaseReady()) throw new Error("The selected local database is not ready for rebuild preparation.");
|
|
56133
|
+
if (!await this.vault.scanVault(true, true)) throw new Error("The Vault could not be scanned for rebuild preparation.");
|
|
56134
|
+
if (!await this.databaseEvents.onDatabaseInitialised(true)) throw new Error("The local database completion hooks failed during rebuild preparation.");
|
|
56135
|
+
if (!await this.fileProcessing.commitPendingFileEvents()) throw new Error("The current file-event batch could not be released for rebuild preparation.");
|
|
56136
|
+
}
|
|
56137
|
+
async completePreparedRebuild() {
|
|
56138
|
+
this.appLifecycle.resetIsReady();
|
|
56139
|
+
if (!this.database.isDatabaseReady()) return false;
|
|
56140
|
+
if (!await this.fileProcessing.commitPendingFileEvents()) return false;
|
|
56141
|
+
this.appLifecycle.markIsReady();
|
|
56142
|
+
return true;
|
|
56012
56143
|
}
|
|
56013
56144
|
async fetchLocal(makeLocalChunkBeforeSync, preventMakeLocalFilesBeforeSync, autoResume = true) {
|
|
56014
56145
|
await this.setting.suspendExtraSync();
|
|
@@ -56046,26 +56177,24 @@ Are you sure you wish to proceed?`;
|
|
|
56046
56177
|
await this.replicator.runBoundedRemoteActivity(() => this.performFetchLocal(makeLocalChunkBeforeSync, preventMakeLocalFilesBeforeSync, autoResume), { label: "rebuild-fetch" });
|
|
56047
56178
|
}
|
|
56048
56179
|
async performFetchLocal(makeLocalChunkBeforeSync, preventMakeLocalFilesBeforeSync, autoResume = true) {
|
|
56180
|
+
this.appLifecycle.resetIsReady();
|
|
56049
56181
|
await this.suspendReflectingDatabase(!autoResume);
|
|
56050
56182
|
await this.control.applySettings();
|
|
56051
56183
|
await this.resetLocalDatabase();
|
|
56052
56184
|
this.clearFastFetchCheckpoint();
|
|
56053
56185
|
await delay$1(1e3);
|
|
56054
|
-
await this.database.openDatabase({
|
|
56055
|
-
databaseEvents: this.databaseEvents,
|
|
56056
|
-
replicator: this.replicator
|
|
56057
|
-
});
|
|
56058
|
-
this.appLifecycle.markIsReady();
|
|
56059
56186
|
if (makeLocalChunkBeforeSync) await this.fileHandler.createAllChunks(true);
|
|
56060
|
-
else if (!preventMakeLocalFilesBeforeSync) await this.
|
|
56187
|
+
else if (!preventMakeLocalFilesBeforeSync) await this.prepareLocalDatabaseForRebuild();
|
|
56061
56188
|
await this.replication.markResolved();
|
|
56062
56189
|
await delay$1(500);
|
|
56063
|
-
await this.replication.
|
|
56190
|
+
if (!await this.replication.replicateAllFromRemoteForRebuild(true)) throw new Error("The first Standard Fetch pass did not complete.");
|
|
56064
56191
|
if (this.setting.currentSettings().remoteType !== REMOTE_P2P) {
|
|
56065
56192
|
await delay$1(1e3);
|
|
56066
|
-
await this.replication.
|
|
56193
|
+
if (!await this.replication.replicateAllFromRemoteForRebuild(true)) throw new Error("The final Standard Fetch pass did not complete.");
|
|
56194
|
+
}
|
|
56195
|
+
if (autoResume) {
|
|
56196
|
+
if (!await this.finishRebuild()) throw new Error("Standard Fetch could not be finalised.");
|
|
56067
56197
|
}
|
|
56068
|
-
if (autoResume) await this.finishRebuild();
|
|
56069
56198
|
}
|
|
56070
56199
|
async fetchLocalDBFast(autoResume) {
|
|
56071
56200
|
await this.setting.suspendExtraSync();
|
|
@@ -56087,31 +56216,28 @@ Are you sure you wish to proceed?`;
|
|
|
56087
56216
|
await this.replicator.runBoundedRemoteActivity(() => this.performFetchLocalDBFast(settings, autoResume), { label: "fast-fetch" });
|
|
56088
56217
|
}
|
|
56089
56218
|
async performFetchLocalDBFast(settings, autoResume) {
|
|
56219
|
+
this.appLifecycle.resetIsReady();
|
|
56090
56220
|
const remote = settings.couchDB_URI.replace(/\/+$/, "") + (settings.couchDB_DBNAME == "" ? "" : "/" + settings.couchDB_DBNAME);
|
|
56091
56221
|
let checkpoint = this.getFastFetchCheckpoint(remote);
|
|
56092
56222
|
await this.suspendReflectingDatabase();
|
|
56093
56223
|
await this.control.applySettings();
|
|
56094
56224
|
let since = checkpoint?.sequence ?? "0";
|
|
56095
|
-
if (checkpoint)
|
|
56096
|
-
|
|
56225
|
+
if (checkpoint) {
|
|
56226
|
+
this._log(`Resuming fast database fetch from sequence: ${checkpoint.sequence}`, 64, "fetch-init-resume");
|
|
56227
|
+
if (!await this.database.openDatabase({
|
|
56228
|
+
databaseEvents: this.databaseEvents,
|
|
56229
|
+
replicator: this.replicator
|
|
56230
|
+
})) throw new Error("The selected local database could not be opened for Fast Fetch.");
|
|
56231
|
+
} else {
|
|
56097
56232
|
await this.resetLocalDatabase();
|
|
56098
56233
|
await delay$1(1e3);
|
|
56099
56234
|
}
|
|
56100
|
-
await this.database.openDatabase({
|
|
56101
|
-
databaseEvents: this.databaseEvents,
|
|
56102
|
-
replicator: this.replicator
|
|
56103
|
-
});
|
|
56104
|
-
this.appLifecycle.markIsReady();
|
|
56105
56235
|
let localDB = this.database.localDatabase.localDatabase;
|
|
56106
56236
|
if (checkpoint && (await localDB.info()).doc_count == 0) {
|
|
56107
56237
|
this._log("Fast fetch checkpoint found, but the local database is empty. Starting from the beginning.", 64, "fetch-init-resume");
|
|
56108
56238
|
this.clearFastFetchCheckpoint();
|
|
56109
56239
|
await this.resetLocalDatabase();
|
|
56110
56240
|
await delay$1(1e3);
|
|
56111
|
-
await this.database.openDatabase({
|
|
56112
|
-
databaseEvents: this.databaseEvents,
|
|
56113
|
-
replicator: this.replicator
|
|
56114
|
-
});
|
|
56115
56241
|
localDB = this.database.localDatabase.localDatabase;
|
|
56116
56242
|
since = "0";
|
|
56117
56243
|
}
|
|
@@ -56137,16 +56263,42 @@ Total bytes fetched: ${sizeToHumanReadable(progress.totalBytes)}`, 64, "fetch-in
|
|
|
56137
56263
|
const allDocs = await localDB.allDocs({ include_docs: false });
|
|
56138
56264
|
this._log(`Fast database fetch completed. Total documents in local database: ${allDocs.total_rows}`, 64, "fetch-init-complete");
|
|
56139
56265
|
await this.replication.markResolved();
|
|
56140
|
-
if (autoResume)
|
|
56266
|
+
if (autoResume) {
|
|
56267
|
+
if (!await this.finishRebuild()) throw new Error("Fast Fetch could not be finalised.");
|
|
56268
|
+
}
|
|
56141
56269
|
this.clearFastFetchCheckpoint();
|
|
56142
56270
|
}
|
|
56143
56271
|
/**
|
|
56144
|
-
*
|
|
56272
|
+
* Complete the final rebuild phases and establish application readiness.
|
|
56145
56273
|
*
|
|
56146
|
-
*
|
|
56274
|
+
* A failed completion restores the previous reflection settings in memory.
|
|
56275
|
+
* Persistence atomicity remains a responsibility of the host setting store;
|
|
56276
|
+
* Commonlib cannot roll back a store which writes successfully and then
|
|
56277
|
+
* reports an error.
|
|
56278
|
+
*
|
|
56279
|
+
* @param ignoreMinIO Whether to resume reflection for a MinIO remote.
|
|
56280
|
+
* @returns `true` when finalisation completed; otherwise, `false`.
|
|
56147
56281
|
*/
|
|
56148
56282
|
async finishRebuild(ignoreMinIO = true) {
|
|
56149
|
-
|
|
56283
|
+
this.appLifecycle.resetIsReady();
|
|
56284
|
+
const settings = this.setting.currentSettings();
|
|
56285
|
+
const controlsReflection = !settings.doNotSuspendOnFetching && (ignoreMinIO || settings.remoteType !== REMOTE_MINIO);
|
|
56286
|
+
const previousReflectionState = {
|
|
56287
|
+
suspendParseReplicationResult: settings.suspendParseReplicationResult,
|
|
56288
|
+
suspendFileWatching: settings.suspendFileWatching
|
|
56289
|
+
};
|
|
56290
|
+
let completed = false;
|
|
56291
|
+
try {
|
|
56292
|
+
if (!this.database.isDatabaseReady()) return false;
|
|
56293
|
+
if (!await this.resumeReflectingDatabase(ignoreMinIO)) return false;
|
|
56294
|
+
if (!await this.fileProcessing.commitPendingFileEvents()) return false;
|
|
56295
|
+
if (controlsReflection) await this.setting.saveSettingData();
|
|
56296
|
+
this.appLifecycle.markIsReady();
|
|
56297
|
+
completed = true;
|
|
56298
|
+
return true;
|
|
56299
|
+
} finally {
|
|
56300
|
+
if (!completed && controlsReflection) await this.setting.applyPartial(previousReflectionState);
|
|
56301
|
+
}
|
|
56150
56302
|
}
|
|
56151
56303
|
/**
|
|
56152
56304
|
* Fetch local database with making all chunks.
|
|
@@ -56162,11 +56314,12 @@ Total bytes fetched: ${sizeToHumanReadable(progress.totalBytes)}`, 64, "fetch-in
|
|
|
56162
56314
|
return true;
|
|
56163
56315
|
}
|
|
56164
56316
|
async resetLocalDatabase() {
|
|
56165
|
-
const settings = this.setting.currentSettings();
|
|
56166
|
-
if (settings.isConfigured && settings.additionalSuffixOfDatabaseName == "") await this.database.resetDatabase();
|
|
56167
56317
|
const suffix = this.API.getAppID() || "";
|
|
56168
56318
|
await this.setting.applyPartial({ additionalSuffixOfDatabaseName: suffix });
|
|
56169
|
-
await this.database.
|
|
56319
|
+
if (!await this.database.resetDatabaseForCurrentSettings({
|
|
56320
|
+
databaseEvents: this.databaseEvents,
|
|
56321
|
+
replicator: this.replicator
|
|
56322
|
+
})) throw new Error("The local database selected by the current settings could not be reset.");
|
|
56170
56323
|
this.events.emitEvent(EVENT_DATABASE_REBUILT);
|
|
56171
56324
|
}
|
|
56172
56325
|
getFastFetchCheckpoint(remote) {
|
|
@@ -56691,24 +56844,17 @@ var ServiceFileHandlerBase = class extends ServiceModuleBase {
|
|
|
56691
56844
|
return true;
|
|
56692
56845
|
}
|
|
56693
56846
|
async _anyHandlerProcessesFileEvent(item) {
|
|
56847
|
+
if (item.restoredFromPreviousRuntime) return await this._processRestoredFileEvent(item);
|
|
56694
56848
|
const eventItem = item.args;
|
|
56695
56849
|
const type = item.type;
|
|
56696
56850
|
const path = eventItem.file.path;
|
|
56697
|
-
if (!await this.
|
|
56698
|
-
this._log(`File ${path} is not the target file`, 16);
|
|
56699
|
-
return false;
|
|
56700
|
-
}
|
|
56701
|
-
if (shouldBeIgnored(path)) {
|
|
56702
|
-
this._log(`File ${path} should be ignored`, 16);
|
|
56703
|
-
return false;
|
|
56704
|
-
}
|
|
56851
|
+
if (!await this.isCurrentPathSelected(path)) return false;
|
|
56705
56852
|
if (type === "RENAME" && !eventItem.oldPath) {
|
|
56706
56853
|
this._log(`Rename event for ${path} has no source path`, 16);
|
|
56707
56854
|
return false;
|
|
56708
56855
|
}
|
|
56709
56856
|
const eventPaths = type === "RENAME" ? [path, eventItem.oldPath] : [path];
|
|
56710
|
-
|
|
56711
|
-
return await serializedByKeys([...new Set(documentIds)].sort().map((documentId) => `processFileEvent-${documentId}`), async () => {
|
|
56857
|
+
return await this.serializedByFileEventPaths(eventPaths, async () => {
|
|
56712
56858
|
switch (type) {
|
|
56713
56859
|
case "CREATE":
|
|
56714
56860
|
case "CHANGED": return await this.storeFileToDB(item.args.file);
|
|
@@ -56721,6 +56867,138 @@ var ServiceFileHandlerBase = class extends ServiceModuleBase {
|
|
|
56721
56867
|
}
|
|
56722
56868
|
});
|
|
56723
56869
|
}
|
|
56870
|
+
async serializedByFileEventPaths(eventPaths, callback) {
|
|
56871
|
+
const documentIds = await Promise.all(eventPaths.map((eventPath) => this.path.path2id(eventPath)));
|
|
56872
|
+
return await serializedByKeys([...new Set(documentIds)].sort().map((documentId) => `processFileEvent-${documentId}`), () => callback(documentIds.length === 2 && documentIds[0] === documentIds[1]));
|
|
56873
|
+
}
|
|
56874
|
+
/**
|
|
56875
|
+
* Revalidate a persisted storage operation against the current storage state.
|
|
56876
|
+
*
|
|
56877
|
+
* Snapshot entries preserve operation intent and ordering only. Their file
|
|
56878
|
+
* stub, timestamps, and existence assumptions can be stale after a restart.
|
|
56879
|
+
* Current inclusion is therefore read from storage, while destructive work
|
|
56880
|
+
* is allowed only after current absence has been observed.
|
|
56881
|
+
*/
|
|
56882
|
+
async _processRestoredFileEvent(item) {
|
|
56883
|
+
const eventItem = item.args;
|
|
56884
|
+
const type = item.type;
|
|
56885
|
+
const path = eventItem.file.path;
|
|
56886
|
+
if (type === "RENAME" && !eventItem.oldPath) {
|
|
56887
|
+
this._log(`Rename event for ${path} has no source path`, 16);
|
|
56888
|
+
return true;
|
|
56889
|
+
}
|
|
56890
|
+
const eventPaths = type === "RENAME" ? [path, eventItem.oldPath] : [path];
|
|
56891
|
+
return await this.serializedByFileEventPaths(eventPaths, async (isSameDocument) => {
|
|
56892
|
+
let action;
|
|
56893
|
+
try {
|
|
56894
|
+
action = await this._planRestoredFileEvent(item, isSameDocument);
|
|
56895
|
+
} catch (ex) {
|
|
56896
|
+
this.logRestoredEventValidationFailure(path, ex);
|
|
56897
|
+
return true;
|
|
56898
|
+
}
|
|
56899
|
+
switch (action.kind) {
|
|
56900
|
+
case "none": return true;
|
|
56901
|
+
case "store": return await this.storeFileToDB(action.file);
|
|
56902
|
+
case "delete": return await this.deleteFileFromDB(action.path);
|
|
56903
|
+
case "rename": return await this.renameFileInDB(action.file, action.oldPath);
|
|
56904
|
+
}
|
|
56905
|
+
});
|
|
56906
|
+
}
|
|
56907
|
+
async _planRestoredFileEvent(item, isSameDocument) {
|
|
56908
|
+
const path = item.args.file.path;
|
|
56909
|
+
switch (item.type) {
|
|
56910
|
+
case "CREATE":
|
|
56911
|
+
case "CHANGED": {
|
|
56912
|
+
const current = this.getExactCurrentFile(await this.storage.getStub(path), path);
|
|
56913
|
+
return current && await this.isCurrentFileSelected(current) ? {
|
|
56914
|
+
kind: "store",
|
|
56915
|
+
file: current
|
|
56916
|
+
} : { kind: "none" };
|
|
56917
|
+
}
|
|
56918
|
+
case "DELETE": return await this.storage.getStub(path) === null && await this.canApplyRestoredDeletion(path) ? {
|
|
56919
|
+
kind: "delete",
|
|
56920
|
+
path
|
|
56921
|
+
} : { kind: "none" };
|
|
56922
|
+
case "RENAME": return await this._planRestoredRename(path, item.args.oldPath, isSameDocument);
|
|
56923
|
+
case "INTERNAL": return { kind: "none" };
|
|
56924
|
+
default:
|
|
56925
|
+
this._log(`Unsupported event type: ${item.type}`, 16);
|
|
56926
|
+
return { kind: "none" };
|
|
56927
|
+
}
|
|
56928
|
+
}
|
|
56929
|
+
async _planRestoredRename(newPath, oldPath, isSameDocument) {
|
|
56930
|
+
if (isSameDocument) {
|
|
56931
|
+
const currentTarget2 = this.getExactCurrentFile(await this.storage.getStub(newPath), newPath);
|
|
56932
|
+
if (!currentTarget2 || !await this.isCurrentFileSelected(currentTarget2)) return { kind: "none" };
|
|
56933
|
+
return {
|
|
56934
|
+
kind: "rename",
|
|
56935
|
+
file: currentTarget2,
|
|
56936
|
+
oldPath
|
|
56937
|
+
};
|
|
56938
|
+
}
|
|
56939
|
+
const currentTargetItem = await this.storage.getStub(newPath);
|
|
56940
|
+
let currentSourceItem = null;
|
|
56941
|
+
let sourceWasInspected = true;
|
|
56942
|
+
try {
|
|
56943
|
+
currentSourceItem = await this.storage.getStub(oldPath);
|
|
56944
|
+
} catch (ex) {
|
|
56945
|
+
sourceWasInspected = false;
|
|
56946
|
+
this.logRestoredEventValidationFailure(oldPath, ex);
|
|
56947
|
+
}
|
|
56948
|
+
const currentTarget = this.getExactCurrentFile(currentTargetItem, newPath);
|
|
56949
|
+
if (currentTargetItem !== null) {
|
|
56950
|
+
if (!currentTarget || !await this.isCurrentFileSelected(currentTarget)) return { kind: "none" };
|
|
56951
|
+
if (!sourceWasInspected || currentSourceItem !== null || !await this.canApplyRestoredDeletion(oldPath)) return {
|
|
56952
|
+
kind: "store",
|
|
56953
|
+
file: currentTarget
|
|
56954
|
+
};
|
|
56955
|
+
return {
|
|
56956
|
+
kind: "rename",
|
|
56957
|
+
file: currentTarget,
|
|
56958
|
+
oldPath
|
|
56959
|
+
};
|
|
56960
|
+
}
|
|
56961
|
+
if (!sourceWasInspected || currentSourceItem !== null || !await this.canApplyRestoredDeletion(oldPath)) return { kind: "none" };
|
|
56962
|
+
return {
|
|
56963
|
+
kind: "delete",
|
|
56964
|
+
path: oldPath
|
|
56965
|
+
};
|
|
56966
|
+
}
|
|
56967
|
+
getExactCurrentFile(current, expectedPath) {
|
|
56968
|
+
if (current === null || isFolderInfo(current)) return null;
|
|
56969
|
+
return this.storage.normalisePath(current.path) === this.storage.normalisePath(expectedPath) ? current : null;
|
|
56970
|
+
}
|
|
56971
|
+
async isCurrentFileSelected(file) {
|
|
56972
|
+
if (!await this.isCurrentPathSelected(file.path)) return false;
|
|
56973
|
+
if (this.vault.isFileSizeTooLarge(file.stat.size)) {
|
|
56974
|
+
this._log(`File ${file.path} exceeds the current maximum size`, 16);
|
|
56975
|
+
return false;
|
|
56976
|
+
}
|
|
56977
|
+
return true;
|
|
56978
|
+
}
|
|
56979
|
+
async isCurrentPathSelected(path) {
|
|
56980
|
+
if (!await this.vault.isTargetFile(path)) {
|
|
56981
|
+
this._log(`File ${path} is not the target file`, 16);
|
|
56982
|
+
return false;
|
|
56983
|
+
}
|
|
56984
|
+
if (shouldBeIgnored(path)) {
|
|
56985
|
+
this._log(`File ${path} should be ignored`, 16);
|
|
56986
|
+
return false;
|
|
56987
|
+
}
|
|
56988
|
+
return true;
|
|
56989
|
+
}
|
|
56990
|
+
async canApplyRestoredDeletion(path) {
|
|
56991
|
+
try {
|
|
56992
|
+
return await this.isCurrentPathSelected(path);
|
|
56993
|
+
} catch (ex) {
|
|
56994
|
+
this.logRestoredEventValidationFailure(path, ex);
|
|
56995
|
+
return false;
|
|
56996
|
+
}
|
|
56997
|
+
}
|
|
56998
|
+
logRestoredEventValidationFailure(path, ex) {
|
|
56999
|
+
this._log(`Could not validate the saved storage operation for ${path} against current storage; the Offline Scanner will reconcile the current state`, 64);
|
|
57000
|
+
this._log(ex, 16);
|
|
57001
|
+
}
|
|
56724
57002
|
async _anyProcessReplicatedDoc(entry) {
|
|
56725
57003
|
return await serialized(`processReplicatedDoc-${entry._id}`, async () => {
|
|
56726
57004
|
if (!await this.vault.isTargetFile(entry.path)) {
|
|
@@ -57939,13 +58217,11 @@ var StorageEventManagerBase = class extends StorageEventManager {
|
|
|
57939
58217
|
}
|
|
57940
58218
|
/**
|
|
57941
58219
|
* Snapshot restoration promise.
|
|
57942
|
-
*
|
|
57943
|
-
* In designed time, this has been called from Initialisation process, which has been implemented on `ModuleInitializerFile.ts`.
|
|
58220
|
+
* It resolves after the restored file operations have finished, before Vault watching begins.
|
|
57944
58221
|
*/
|
|
57945
58222
|
snapShotRestored = null;
|
|
57946
58223
|
/**
|
|
57947
|
-
* Restore the previous snapshot
|
|
57948
|
-
* @returns
|
|
58224
|
+
* Restore and complete the previous storage-event snapshot when it exists.
|
|
57949
58225
|
*/
|
|
57950
58226
|
restoreState() {
|
|
57951
58227
|
this.snapShotRestored = this._restoreFromSnapshot();
|
|
@@ -58203,16 +58479,39 @@ var StorageEventManagerBase = class extends StorageEventManager {
|
|
|
58203
58479
|
const snapShot = await this._loadSnapshot();
|
|
58204
58480
|
if (snapShot && Array.isArray(snapShot) && snapShot.length > 0) {
|
|
58205
58481
|
this._log(`Restoring storage operation snapshot: ${snapShot.length} items`, 16);
|
|
58206
|
-
this.bufferedQueuedItems = snapShot.map((
|
|
58207
|
-
...
|
|
58482
|
+
this.bufferedQueuedItems = snapShot.map((event) => event.type === TYPE_SENTINEL_FLUSH ? event : {
|
|
58483
|
+
...event,
|
|
58484
|
+
restoredFromPreviousRuntime: true,
|
|
58208
58485
|
skipBatchWait: true
|
|
58209
|
-
})
|
|
58486
|
+
});
|
|
58210
58487
|
this.updateStatus();
|
|
58211
|
-
await this.runQueuedEvents();
|
|
58488
|
+
await this.runQueuedEvents({ waitForProcessing: true });
|
|
58212
58489
|
} else this._log(`No snapshot to restore`, 16);
|
|
58213
58490
|
}
|
|
58214
|
-
|
|
58491
|
+
/**
|
|
58492
|
+
* Dispatch buffered storage events.
|
|
58493
|
+
*
|
|
58494
|
+
* Ordinary watcher events retain the existing fire-and-forget behaviour.
|
|
58495
|
+
* Snapshot restoration requests completion so its caller can use the replay as
|
|
58496
|
+
* a lifecycle boundary. In that mode, a sentinel also waits for every operation
|
|
58497
|
+
* dispatched before it, preserving the ordering represented by the snapshot.
|
|
58498
|
+
* An individual restored operation failure is logged but does not prevent the
|
|
58499
|
+
* following Offline Scanner from reconciling the resulting current state.
|
|
58500
|
+
*/
|
|
58501
|
+
runQueuedEvents(options = {}) {
|
|
58502
|
+
const waitForProcessing = options.waitForProcessing ?? false;
|
|
58215
58503
|
return skipIfDuplicated("storage-event-manager-run-queued-events", async () => {
|
|
58504
|
+
let dispatched = [];
|
|
58505
|
+
const waitForDispatched = async () => {
|
|
58506
|
+
if (dispatched.length === 0) return;
|
|
58507
|
+
const pending = dispatched;
|
|
58508
|
+
dispatched = [];
|
|
58509
|
+
const results = await Promise.allSettled(pending.map(({ processing }) => processing));
|
|
58510
|
+
for (const [index, result] of results.entries()) if (result.status === "rejected") {
|
|
58511
|
+
this._log(`Restored storage operation failed for ${pending[index].path}; the Offline Scanner will reconcile the current state`, 64);
|
|
58512
|
+
this._log(result.reason, 16);
|
|
58513
|
+
}
|
|
58514
|
+
};
|
|
58216
58515
|
do {
|
|
58217
58516
|
if (this.bufferedQueuedItems.length === 0) break;
|
|
58218
58517
|
const fei = this.bufferedQueuedItems.shift();
|
|
@@ -58222,12 +58521,19 @@ var StorageEventManagerBase = class extends StorageEventManager {
|
|
|
58222
58521
|
this.updateStatus();
|
|
58223
58522
|
if (fei.type === TYPE_SENTINEL_FLUSH) {
|
|
58224
58523
|
this._log(`Waiting for idle`, 16);
|
|
58524
|
+
if (waitForProcessing) await waitForDispatched();
|
|
58225
58525
|
await this.waitForIdle();
|
|
58226
58526
|
this.updateStatus();
|
|
58227
58527
|
continue;
|
|
58228
58528
|
}
|
|
58229
|
-
|
|
58529
|
+
const processing = this.processFileEvent(fei);
|
|
58530
|
+
if (waitForProcessing) dispatched.push({
|
|
58531
|
+
path: fei.args.file.path,
|
|
58532
|
+
processing
|
|
58533
|
+
});
|
|
58534
|
+
else fireAndForget(processing);
|
|
58230
58535
|
} while (this.bufferedQueuedItems.length > 0);
|
|
58536
|
+
if (waitForProcessing) await waitForDispatched();
|
|
58231
58537
|
});
|
|
58232
58538
|
}
|
|
58233
58539
|
processingCount = 0;
|
|
@@ -58665,6 +58971,7 @@ function initialiseServiceModulesCLI(basePath, core, services, ignoreRules, watc
|
|
|
58665
58971
|
UI: services.UI,
|
|
58666
58972
|
vault: services.vault,
|
|
58667
58973
|
fileHandler,
|
|
58974
|
+
fileProcessing: services.fileProcessing,
|
|
58668
58975
|
storageAccess,
|
|
58669
58976
|
control: services.control
|
|
58670
58977
|
}),
|
|
@@ -65839,7 +66146,7 @@ function generateJoinRoomOptions(settings) {
|
|
|
65839
66146
|
const passphraseNumbers = mixedHash(settings.P2P_passphrase, 0);
|
|
65840
66147
|
const passphrase = passphraseNumbers[0].toString(36) + passphraseNumbers[1].toString(36);
|
|
65841
66148
|
const relays = settings.P2P_relays.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
65842
|
-
const turnServers = settings.P2P_turnServers
|
|
66149
|
+
const turnServers = splitP2PTurnServerUrls(settings.P2P_turnServers);
|
|
65843
66150
|
const relayConfig = {
|
|
65844
66151
|
manualReconnection: true,
|
|
65845
66152
|
urls: relays
|
|
@@ -65856,6 +66163,7 @@ function generateJoinRoomOptions(settings) {
|
|
|
65856
66163
|
username: settings.P2P_turnUsername,
|
|
65857
66164
|
credential: settings.P2P_turnCredential
|
|
65858
66165
|
}];
|
|
66166
|
+
if (normaliseP2PConnectionPath(settings.P2P_connectionPath) === P2PConnectionPaths.Relay && hasValidP2PTurnServerUrl(settings.P2P_turnServers)) options.rtcConfig = { iceTransportPolicy: "relay" };
|
|
65859
66167
|
return options;
|
|
65860
66168
|
}
|
|
65861
66169
|
//#endregion
|
|
@@ -65899,6 +66207,12 @@ var TRYSTERO_RPC_DEFAULTS = {
|
|
|
65899
66207
|
/** SCTP guarantees delivery; retransmission is a last-resort safety net. */
|
|
65900
66208
|
chunkMissingRetryMs: 150
|
|
65901
66209
|
};
|
|
66210
|
+
function resolveTrysteroRpcOptions(settings) {
|
|
66211
|
+
return {
|
|
66212
|
+
...TRYSTERO_RPC_DEFAULTS,
|
|
66213
|
+
maxWirePayloadBytes: normaliseP2PMaxWirePayloadBytes(settings.P2P_maxWirePayloadBytes)
|
|
66214
|
+
};
|
|
66215
|
+
}
|
|
65902
66216
|
//#endregion
|
|
65903
66217
|
//#region ../../../node_modules/@vrtmrz/livesync-commonlib/dist/replication/trystero/TrysteroReplicatorP2PServer.js
|
|
65904
66218
|
var EVENT_SERVER_STATUS = "p2p-server-status";
|
|
@@ -66207,7 +66521,7 @@ You can chose as follows:
|
|
|
66207
66521
|
};
|
|
66208
66522
|
this._rpcRoom?.close();
|
|
66209
66523
|
this._rpcRoom = new RpcRoom({
|
|
66210
|
-
...
|
|
66524
|
+
...resolveTrysteroRpcOptions(this.settings),
|
|
66211
66525
|
transport,
|
|
66212
66526
|
canAcceptRequest: async (peerId, method) => {
|
|
66213
66527
|
if (method === toRpcMethodName("!reqAuth")) return true;
|
|
@@ -66852,6 +67166,7 @@ var LiveSyncTrysteroReplicator = class extends LiveSyncAbstractReplicator {
|
|
|
66852
67166
|
_replicator;
|
|
66853
67167
|
_lifecycleOperation = Promise.resolve();
|
|
66854
67168
|
_shouldBeOpen = false;
|
|
67169
|
+
_activeTransportCompatibilitySignature;
|
|
66855
67170
|
get openReplicationUI() {
|
|
66856
67171
|
return this.env.openReplicationUI;
|
|
66857
67172
|
}
|
|
@@ -66905,6 +67220,25 @@ var LiveSyncTrysteroReplicator = class extends LiveSyncAbstractReplicator {
|
|
|
66905
67220
|
this._lifecycleOperation = queued.catch(() => void 0);
|
|
66906
67221
|
return queued;
|
|
66907
67222
|
}
|
|
67223
|
+
/**
|
|
67224
|
+
* Capture settings which are fixed when the active P2P transport joins its room.
|
|
67225
|
+
* A later open request can remain idempotent only while these effective values match.
|
|
67226
|
+
*/
|
|
67227
|
+
_getTransportCompatibilitySignature() {
|
|
67228
|
+
const settings = this.env.services.setting.currentSettings();
|
|
67229
|
+
const effectivePath = normaliseP2PConnectionPath(settings.P2P_connectionPath) === P2PConnectionPaths.Relay && hasValidP2PTurnServerUrl(settings.P2P_turnServers ?? "") ? P2PConnectionPaths.Relay : P2PConnectionPaths.Automatic;
|
|
67230
|
+
return `${normaliseP2PMaxWirePayloadBytes(settings.P2P_maxWirePayloadBytes)}:${effectivePath}`;
|
|
67231
|
+
}
|
|
67232
|
+
/** Close and forget the transport without changing the requested lifecycle state. */
|
|
67233
|
+
async _closeTransport() {
|
|
67234
|
+
if (this._replicator) {
|
|
67235
|
+
this._replicator.disableBroadcastChanges();
|
|
67236
|
+
await this._replicator.close();
|
|
67237
|
+
this._replicator = void 0;
|
|
67238
|
+
}
|
|
67239
|
+
this._p2pHost = void 0;
|
|
67240
|
+
this._activeTransportCompatibilitySignature = void 0;
|
|
67241
|
+
}
|
|
66908
67242
|
async open() {
|
|
66909
67243
|
if (!this.env.services.setting.currentSettings().P2P_Enabled) {
|
|
66910
67244
|
Logger(this.translate("P2P.NotEnabled"), 64);
|
|
@@ -66913,9 +67247,13 @@ var LiveSyncTrysteroReplicator = class extends LiveSyncAbstractReplicator {
|
|
|
66913
67247
|
this._shouldBeOpen = true;
|
|
66914
67248
|
await this._enqueueLifecycleOperation(async () => {
|
|
66915
67249
|
if (!this._shouldBeOpen) return;
|
|
67250
|
+
const compatibilitySignature = this._getTransportCompatibilitySignature();
|
|
66916
67251
|
if (this._replicator && this._p2pHost?.isServing) {
|
|
66917
|
-
|
|
66918
|
-
|
|
67252
|
+
if (this._activeTransportCompatibilitySignature === compatibilitySignature) {
|
|
67253
|
+
Logger("P2P replicator is already open.");
|
|
67254
|
+
return;
|
|
67255
|
+
}
|
|
67256
|
+
await this._closeTransport();
|
|
66919
67257
|
}
|
|
66920
67258
|
try {
|
|
66921
67259
|
const env = this._buildEnv();
|
|
@@ -66924,23 +67262,20 @@ var LiveSyncTrysteroReplicator = class extends LiveSyncAbstractReplicator {
|
|
|
66924
67262
|
this._p2pHost = host;
|
|
66925
67263
|
this._replicator = replicator;
|
|
66926
67264
|
await replicator.open();
|
|
67265
|
+
this._activeTransportCompatibilitySignature = compatibilitySignature;
|
|
66927
67266
|
} catch (e) {
|
|
66928
67267
|
Logger(e instanceof Error ? e.message : "Error while opening P2P connection", 64);
|
|
66929
67268
|
Logger(e, 16);
|
|
66930
67269
|
this._p2pHost = void 0;
|
|
66931
67270
|
this._replicator = void 0;
|
|
67271
|
+
this._activeTransportCompatibilitySignature = void 0;
|
|
66932
67272
|
}
|
|
66933
67273
|
});
|
|
66934
67274
|
}
|
|
66935
67275
|
async close() {
|
|
66936
67276
|
this._shouldBeOpen = false;
|
|
66937
67277
|
await this._enqueueLifecycleOperation(async () => {
|
|
66938
|
-
|
|
66939
|
-
this._replicator.disableBroadcastChanges();
|
|
66940
|
-
await this._replicator.close();
|
|
66941
|
-
this._replicator = void 0;
|
|
66942
|
-
}
|
|
66943
|
-
this._p2pHost = void 0;
|
|
67278
|
+
await this._closeTransport();
|
|
66944
67279
|
});
|
|
66945
67280
|
}
|
|
66946
67281
|
closeReplication() {
|