mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-02-22 20:18:48 +00:00
Rewritten
- Hidden File Sync is now respects the file changes on the storage. Not simply comparing modified times.
- This makes hidden file sync more robust and reliable.
Fixed
- `Scan hidden files before replication` is now configurable again.
- Some unexpected errors are now handled more gracefully.
- Meaningless event passing during boot sequence is now prevented.
- Error handling for non-existing files has been fixed.
- Hidden files will not be batched to avoid the potential error.
- This behaviour had been causing the error in the previous versions in specific situations.
- The log which checking automatic conflict resolution is now in verbose level.
- Replication log (skipping non-targetting files) shows the correct information.
- The dialogue that asking enabling optional feature during `Rebuild Everything` now prevents to show the `overwrite` option.
- The rebuilding device is the first, meaningless.
- Files with different modified time but identical content are no longer processed repeatedly.
- Some unexpected errors which caused after terminating plug-in are now avoided.
-
Improved
- JSON files are now more transferred efficiently.
- Now the JSON files are transferred in more fine chunks, which makes the transfer more efficient.
93 lines
2.7 KiB
TypeScript
93 lines
2.7 KiB
TypeScript
import { LOG_LEVEL_VERBOSE, Logger } from "octagonal-wheels/common/logger";
|
|
import { getPath } from "../common/utils.ts";
|
|
import {
|
|
LOG_LEVEL_INFO,
|
|
LOG_LEVEL_NOTICE,
|
|
type AnyEntry,
|
|
type DocumentID,
|
|
type EntryHasPath,
|
|
type FilePath,
|
|
type FilePathWithPrefix,
|
|
type LOG_LEVEL,
|
|
} from "../lib/src/common/types.ts";
|
|
import type ObsidianLiveSyncPlugin from "../main.ts";
|
|
import { MARK_DONE } from "../modules/features/ModuleLog.ts";
|
|
|
|
let noticeIndex = 0;
|
|
export abstract class LiveSyncCommands {
|
|
plugin: ObsidianLiveSyncPlugin;
|
|
get app() {
|
|
return this.plugin.app;
|
|
}
|
|
get settings() {
|
|
return this.plugin.settings;
|
|
}
|
|
get localDatabase() {
|
|
return this.plugin.localDatabase;
|
|
}
|
|
|
|
id2path(id: DocumentID, entry?: EntryHasPath, stripPrefix?: boolean): FilePathWithPrefix {
|
|
return this.plugin.$$id2path(id, entry, stripPrefix);
|
|
}
|
|
async path2id(filename: FilePathWithPrefix | FilePath, prefix?: string): Promise<DocumentID> {
|
|
return await this.plugin.$$path2id(filename, prefix);
|
|
}
|
|
getPath(entry: AnyEntry): FilePathWithPrefix {
|
|
return getPath(entry);
|
|
}
|
|
|
|
constructor(plugin: ObsidianLiveSyncPlugin) {
|
|
this.plugin = plugin;
|
|
}
|
|
abstract onunload(): void;
|
|
abstract onload(): void | Promise<void>;
|
|
|
|
_isMainReady() {
|
|
return this.plugin.$$isReady();
|
|
}
|
|
_isMainSuspended() {
|
|
return this.plugin.$$isSuspended();
|
|
}
|
|
_isDatabaseReady() {
|
|
return this.plugin.$$isDatabaseReady();
|
|
}
|
|
|
|
_log = (msg: any, level: LOG_LEVEL = LOG_LEVEL_INFO, key?: string) => {
|
|
if (typeof msg === "string" && level !== LOG_LEVEL_NOTICE) {
|
|
msg = `[${this.constructor.name}]\u{200A} ${msg}`;
|
|
}
|
|
// console.log(msg);
|
|
Logger(msg, level, key);
|
|
};
|
|
|
|
_verbose = (msg: any, key?: string) => {
|
|
this._log(msg, LOG_LEVEL_VERBOSE, key);
|
|
};
|
|
|
|
_info = (msg: any, key?: string) => {
|
|
this._log(msg, LOG_LEVEL_INFO, key);
|
|
};
|
|
|
|
_notice = (msg: any, key?: string) => {
|
|
this._log(msg, LOG_LEVEL_NOTICE, key);
|
|
};
|
|
_progress = (prefix: string = "", level: LOG_LEVEL = LOG_LEVEL_NOTICE) => {
|
|
const key = `keepalive-progress-${noticeIndex++}`;
|
|
return {
|
|
log: (msg: any) => {
|
|
this._log(prefix + msg, level, key);
|
|
},
|
|
once: (msg: any) => {
|
|
this._log(prefix + msg, level);
|
|
},
|
|
done: (msg: string = "Done") => {
|
|
this._log(prefix + msg + MARK_DONE, level, key);
|
|
},
|
|
};
|
|
};
|
|
|
|
_debug = (msg: any, key?: string) => {
|
|
this._log(msg, LOG_LEVEL_VERBOSE, key);
|
|
};
|
|
}
|