- Rewritten lock acquiring logic.
- Fixed plugin dialog's message.
- Fixed some error messages.
- Fixed action on replicating non-note entries.
This commit is contained in:
vorotamoroz
2022-06-14 19:01:31 +09:00
parent 46ff17fdf3
commit dcfb9867f2
7 changed files with 64 additions and 56 deletions

View File

@@ -1,7 +1,7 @@
{ {
"id": "obsidian-livesync", "id": "obsidian-livesync",
"name": "Self-hosted LiveSync", "name": "Self-hosted LiveSync",
"version": "0.11.1", "version": "0.11.2",
"minAppVersion": "0.9.12", "minAppVersion": "0.9.12",
"description": "Community implementation of self-hosted livesync. Reflect your vault changes to some other devices immediately. Please make sure to disable other synchronize solutions to avoid content corruption or duplication.", "description": "Community implementation of self-hosted livesync. Reflect your vault changes to some other devices immediately. Please make sure to disable other synchronize solutions to avoid content corruption or duplication.",
"author": "vorotamoroz", "author": "vorotamoroz",

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "obsidian-livesync", "name": "obsidian-livesync",
"version": "0.11.1", "version": "0.11.2",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "obsidian-livesync", "name": "obsidian-livesync",
"version": "0.11.1", "version": "0.11.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"diff-match-patch": "^1.0.5", "diff-match-patch": "^1.0.5",

View File

@@ -1,6 +1,6 @@
{ {
"name": "obsidian-livesync", "name": "obsidian-livesync",
"version": "0.11.1", "version": "0.11.2",
"description": "Reflect your vault changes to some other devices immediately. Please make sure to disable other synchronize solutions to avoid content corruption or duplication.", "description": "Reflect your vault changes to some other devices immediately. Please make sure to disable other synchronize solutions to avoid content corruption or duplication.",
"main": "main.js", "main": "main.js",
"type": "module", "type": "module",

View File

@@ -315,7 +315,7 @@ export class LocalPouchDB {
this.hashCaches.set(id, w.data); this.hashCaches.set(id, w.data);
return w.data; return w.data;
} }
throw new Error(`Corrupted chunk detected.`); throw new Error(`Corrupted chunk detected: ${id}`);
} catch (ex) { } catch (ex) {
if (ex.status && ex.status == 404) { if (ex.status && ex.status == 404) {
if (waitForReady) { if (waitForReady) {
@@ -326,7 +326,7 @@ export class LocalPouchDB {
} }
return this.getDBLeaf(id, false); return this.getDBLeaf(id, false);
} else { } else {
throw new Error("Chunk was not found"); throw new Error(`Chunk was not found: ${id}`);
} }
} else { } else {
Logger(`Something went wrong on retriving chunk`); Logger(`Something went wrong on retriving chunk`);
@@ -437,7 +437,7 @@ export class LocalPouchDB {
Logger(childrens); Logger(childrens);
} }
} catch (ex) { } catch (ex) {
Logger(`Something went wrong on reading chunks of ${obj._id} from database:`, LOG_LEVEL.NOTICE); Logger(`Something went wrong on reading chunks of ${obj._id} from database, see verbose info for detail.`, LOG_LEVEL.NOTICE);
Logger(ex, LOG_LEVEL.VERBOSE); Logger(ex, LOG_LEVEL.VERBOSE);
this.corruptedEntries[obj._id] = obj; this.corruptedEntries[obj._id] = obj;
return false; return false;

View File

@@ -16,7 +16,7 @@
export let plugin: ObsidianLiveSyncPlugin; export let plugin: ObsidianLiveSyncPlugin;
let plugins: PluginDataEntry[] = []; let plugins: PluginDataEntry[] = [];
let deviceAndPlugins: { [key: string]: PluginDataEntryDisp[] } = {}; let deviceAndPlugins: { [key: string]: PluginDataEntryDisp[] } = {};
let devicePluginList: [string, PluginDataEntryDisp[]][] = []; let devicePluginList: [string, PluginDataEntryDisp[]][] = null;
let ownPlugins: DevicePluginList = null; let ownPlugins: DevicePluginList = null;
let showOwnPlugins = false; let showOwnPlugins = false;
let targetList: { [key: string]: boolean } = {}; let targetList: { [key: string]: boolean } = {};
@@ -205,11 +205,15 @@
<th class="sls-plugins-tbl-device-head">Info</th> <th class="sls-plugins-tbl-device-head">Info</th>
<th class="sls-plugins-tbl-device-head">Target</th> <th class="sls-plugins-tbl-device-head">Target</th>
</tr> </tr>
{#if devicePluginList.length == 0} {#if !devicePluginList}
<tr> <tr>
<td colspan="3" class="sls-table-tail tcenter"> Retrieving... </td> <td colspan="3" class="sls-table-tail tcenter"> Retrieving... </td>
</tr> </tr>
{/if} {:else if devicePluginList.length == 0}
<tr>
<td colspan="3" class="sls-table-tail tcenter"> No plugins found. </td>
</tr>
{:else}
{#each devicePluginList as [deviceName, devicePlugins]} {#each devicePluginList as [deviceName, devicePlugins]}
<tr> <tr>
<th colspan="2" class="sls-plugins-tbl-device-head">{deviceName}</th> <th colspan="2" class="sls-plugins-tbl-device-head">{deviceName}</th>
@@ -257,6 +261,7 @@
</tr> </tr>
{/each} {/each}
{/each} {/each}
{/if}
</table> </table>
</div> </div>
<div class="ols-plugins-div-buttons"> <div class="ols-plugins-div-buttons">

Submodule src/lib updated: ae989051b5...6451afd112

View File

@@ -968,9 +968,11 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
const now = new Date().getTime(); const now = new Date().getTime();
if (queue.missingChildren.length == 0) { if (queue.missingChildren.length == 0) {
queue.done = true; queue.done = true;
if (isValidPath(id2path(queue.entry._id))) {
Logger(`Applying ${queue.entry._id} (${queue.entry._rev}) change...`); Logger(`Applying ${queue.entry._id} (${queue.entry._rev}) change...`);
await this.handleDBChanged(queue.entry); await this.handleDBChanged(queue.entry);
} }
}
if (now > queue.timeout) { if (now > queue.timeout) {
if (!queue.warned) Logger(`Timed out: ${queue.entry._id} could not collect ${queue.missingChildren.length} chunks. plugin keeps watching, but you have to check the file after the replication.`, LOG_LEVEL.NOTICE); if (!queue.warned) Logger(`Timed out: ${queue.entry._id} could not collect ${queue.missingChildren.length} chunks. plugin keeps watching, but you have to check the file after the replication.`, LOG_LEVEL.NOTICE);
queue.warned = true; queue.warned = true;
@@ -1733,7 +1735,8 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
async sweepPlugin(showMessage = false) { async sweepPlugin(showMessage = false) {
if (!this.settings.usePluginSync) return; if (!this.settings.usePluginSync) return;
await runWithLock("sweepplugin", false, async () => { if (!this.localDatabase.isReady) return;
await runWithLock("sweepplugin", true, async () => {
const logLevel = showMessage ? LOG_LEVEL.NOTICE : LOG_LEVEL.INFO; const logLevel = showMessage ? LOG_LEVEL.NOTICE : LOG_LEVEL.INFO;
if (!this.settings.encrypt) { if (!this.settings.encrypt) {
Logger("You have to encrypt the database to use plugin setting sync.", LOG_LEVEL.NOTICE); Logger("You have to encrypt the database to use plugin setting sync.", LOG_LEVEL.NOTICE);