- Prettified some source.

- Fixed the issue which the filename is shown as `undefined`.
- Fixed the issue where files transferred at short intervals were not reflected.
- Updated dependency (including new translation)
This commit is contained in:
vorotamoroz
2025-02-05 00:58:51 +00:00
parent f2b667d75e
commit 54e64c59a9
3 changed files with 34 additions and 37 deletions
+1 -1
Submodule src/lib updated: 6305e8952b...90ace6de16
+4 -7
View File
@@ -205,13 +205,10 @@ export class ModuleFileHandler extends AbstractModule implements ICoreModule {
): Promise<boolean> { ): Promise<boolean> {
const file = typeof info === "string" ? this.storage.getFileStub(info) : info; const file = typeof info === "string" ? this.storage.getFileStub(info) : info;
const mode = file == null ? "create" : "modify"; const mode = file == null ? "create" : "modify";
const pathFromEntryInfo = typeof entryInfo === "string" ? entryInfo : getPath(entryInfo);
const docEntry = const docEntry = await this.db.fetchEntryMeta(pathFromEntryInfo, undefined, true);
typeof entryInfo === "string"
? await this.db.fetchEntryMeta(entryInfo, undefined, true)
: await this.db.fetchEntryMeta(entryInfo.path, undefined, true);
if (!docEntry) { if (!docEntry) {
this._log(`File ${file?.path} is not exist on the database`, LOG_LEVEL_VERBOSE); this._log(`File ${pathFromEntryInfo} is not exist on the database`, LOG_LEVEL_VERBOSE);
return false; return false;
} }
const path = getPath(docEntry); const path = getPath(docEntry);
@@ -275,7 +272,7 @@ export class ModuleFileHandler extends AbstractModule implements ICoreModule {
} }
// 2. if not, the content should be checked. // 2. if not, the content should be checked.
if (shouldApplied) { if (!shouldApplied) {
const readFile = await this.readFileFromStub(existDoc); const readFile = await this.readFileFromStub(existDoc);
if (await isDocContentSame(docData, readFile.body)) { if (await isDocContentSame(docData, readFile.body)) {
// The content is same. So, we do not need to update the file. // The content is same. So, we do not need to update the file.
@@ -119,10 +119,10 @@ function getLevelStr(level: ConfigLevel) {
return level == LEVEL_POWER_USER return level == LEVEL_POWER_USER
? " (Power User)" ? " (Power User)"
: level == LEVEL_ADVANCED : level == LEVEL_ADVANCED
? " (Advanced)" ? " (Advanced)"
: level == LEVEL_EDGE_CASE : level == LEVEL_EDGE_CASE
? " (Edge Case)" ? " (Edge Case)"
: ""; : "";
} }
export function findAttrFromParent(el: HTMLElement, attr: string): string { export function findAttrFromParent(el: HTMLElement, attr: string): string {
@@ -301,8 +301,8 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
const syncMode = this.editingSettings?.liveSync const syncMode = this.editingSettings?.liveSync
? "LIVESYNC" ? "LIVESYNC"
: this.editingSettings?.periodicReplication : this.editingSettings?.periodicReplication
? "PERIODIC" ? "PERIODIC"
: "ONEVENTS"; : "ONEVENTS";
return { return {
syncMode, syncMode,
}; };
@@ -1652,16 +1652,16 @@ I appreciate you for your great dedication.
const options: Record<string, string> = const options: Record<string, string> =
this.editingSettings.remoteType == REMOTE_COUCHDB this.editingSettings.remoteType == REMOTE_COUCHDB
? { ? {
NONE: "", NONE: "",
LIVESYNC: "LiveSync", LIVESYNC: "LiveSync",
PERIODIC: "Periodic w/ batch", PERIODIC: "Periodic w/ batch",
DISABLE: "Disable all automatic", DISABLE: "Disable all automatic",
} }
: { : {
NONE: "", NONE: "",
PERIODIC: "Periodic w/ batch", PERIODIC: "Periodic w/ batch",
DISABLE: "Disable all automatic", DISABLE: "Disable all automatic",
}; };
new Setting(paneEl) new Setting(paneEl)
.autoWireDropDown("preset", { .autoWireDropDown("preset", {
@@ -1768,10 +1768,10 @@ I appreciate you for your great dedication.
const optionsSyncMode = const optionsSyncMode =
this.editingSettings.remoteType == REMOTE_COUCHDB this.editingSettings.remoteType == REMOTE_COUCHDB
? { ? {
ONEVENTS: "On events", ONEVENTS: "On events",
PERIODIC: "Periodic and on events", PERIODIC: "Periodic and on events",
LIVESYNC: "LiveSync", LIVESYNC: "LiveSync",
} }
: { ONEVENTS: "On events", PERIODIC: "Periodic and on events" }; : { ONEVENTS: "On events", PERIODIC: "Periodic and on events" };
new Setting(paneEl) new Setting(paneEl)
@@ -2050,7 +2050,7 @@ I appreciate you for your great dedication.
text: "Please set device name to identify this device. This name should be unique among your devices. While not configured, we cannot enable this feature.", text: "Please set device name to identify this device. This name should be unique among your devices. While not configured, we cannot enable this feature.",
cls: "op-warn", cls: "op-warn",
}, },
(c) => { }, (c) => {},
visibleOnly(() => this.isConfiguredAs("deviceAndVaultName", "")) visibleOnly(() => this.isConfiguredAs("deviceAndVaultName", ""))
); );
this.createEl( this.createEl(
@@ -2060,7 +2060,7 @@ I appreciate you for your great dedication.
text: "We cannot change the device name while this feature is enabled. Please disable this feature to change the device name.", text: "We cannot change the device name while this feature is enabled. Please disable this feature to change the device name.",
cls: "op-warn-info", cls: "op-warn-info",
}, },
(c) => { }, (c) => {},
visibleOnly(() => this.isConfiguredAs("usePluginSync", true)) visibleOnly(() => this.isConfiguredAs("usePluginSync", true))
); );
@@ -2152,8 +2152,8 @@ I appreciate you for your great dedication.
const scheme = pluginConfig.couchDB_URI.startsWith("http:") const scheme = pluginConfig.couchDB_URI.startsWith("http:")
? "(HTTP)" ? "(HTTP)"
: pluginConfig.couchDB_URI.startsWith("https:") : pluginConfig.couchDB_URI.startsWith("https:")
? "(HTTPS)" ? "(HTTPS)"
: ""; : "";
pluginConfig.couchDB_URI = isCloudantURI(pluginConfig.couchDB_URI) pluginConfig.couchDB_URI = isCloudantURI(pluginConfig.couchDB_URI)
? "cloudant" ? "cloudant"
: `self-hosted${scheme}`; : `self-hosted${scheme}`;
@@ -2173,8 +2173,8 @@ I appreciate you for your great dedication.
const endpointScheme = pluginConfig.endpoint.startsWith("http:") const endpointScheme = pluginConfig.endpoint.startsWith("http:")
? "(HTTP)" ? "(HTTP)"
: pluginConfig.endpoint.startsWith("https:") : pluginConfig.endpoint.startsWith("https:")
? "(HTTPS)" ? "(HTTPS)"
: ""; : "";
pluginConfig.endpoint = `${endpoint.indexOf(".r2.cloudflarestorage.") !== -1 ? "R2" : "self-hosted?"}(${endpointScheme})`; pluginConfig.endpoint = `${endpoint.indexOf(".r2.cloudflarestorage.") !== -1 ? "R2" : "self-hosted?"}(${endpointScheme})`;
} }
const obsidianInfo = `Navigator: ${navigator.userAgent} const obsidianInfo = `Navigator: ${navigator.userAgent}
@@ -2385,10 +2385,10 @@ ${stringifyYaml(pluginConfig)}`;
Logger("Start verifying all files", LOG_LEVEL_NOTICE, "verify"); Logger("Start verifying all files", LOG_LEVEL_NOTICE, "verify");
const files = this.plugin.settings.syncInternalFiles const files = this.plugin.settings.syncInternalFiles
? await this.plugin.storageAccess.getFilesIncludeHidden( ? await this.plugin.storageAccess.getFilesIncludeHidden(
"/", "/",
undefined, undefined,
ignorePatterns ignorePatterns
) )
: await this.plugin.storageAccess.getFileNames(); : await this.plugin.storageAccess.getFileNames();
const documents = [] as FilePath[]; const documents = [] as FilePath[];