Compare commits

...

2 Commits

Author SHA1 Message Date
vorotamoroz
5c96c7f99b bump 2023-08-08 10:45:50 +01:00
vorotamoroz
7b9724f713 Fixed:
- Now nested ignore files could be parsed correctly.
- The unexpected deletion of hidden files in some cases has been corrected.
- Hidden file change is no longer reflected on the device which has made the change itself.
2023-08-08 10:42:07 +01:00
8 changed files with 64 additions and 52 deletions

View File

@@ -1,7 +1,7 @@
{
"id": "obsidian-livesync",
"name": "Self-hosted LiveSync",
"version": "0.19.16",
"version": "0.19.17",
"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.",
"author": "vorotamoroz",

4
package-lock.json generated
View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "obsidian-livesync",
"version": "0.19.16",
"version": "0.19.17",
"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",
"type": "module",

View File

@@ -273,7 +273,7 @@ export class HiddenFileSync extends LiveSyncCommands {
if (!filename) continue;
if (ignorePatterns.some(e => filename.match(e)))
continue;
if (!await this.plugin.isIgnoredByIgnoreFiles(filename)) {
if (await this.plugin.isIgnoredByIgnoreFiles(filename)) {
continue
}
@@ -434,7 +434,7 @@ export class HiddenFileSync extends LiveSyncCommands {
}
async storeInternalFileToDatabase(file: InternalFileInfo, forceWrite = false) {
if (!await this.plugin.isIgnoredByIgnoreFiles(file.path)) {
if (await this.plugin.isIgnoredByIgnoreFiles(file.path)) {
return
}
const id = await this.path2id(file.path, ICHeader);
@@ -498,7 +498,7 @@ export class HiddenFileSync extends LiveSyncCommands {
const id = await this.path2id(filename, ICHeader);
const prefixedFileName = addPrefix(filename, ICHeader);
const mtime = new Date().getTime();
if (!await this.plugin.isIgnoredByIgnoreFiles(filename)) {
if (await this.plugin.isIgnoredByIgnoreFiles(filename)) {
return
}
await runWithLock("file-" + prefixedFileName, false, async () => {
@@ -544,7 +544,7 @@ export class HiddenFileSync extends LiveSyncCommands {
async extractInternalFileFromDatabase(filename: FilePath, force = false) {
const isExists = await this.app.vault.adapter.exists(filename);
const prefixedFileName = addPrefix(filename, ICHeader);
if (!await this.plugin.isIgnoredByIgnoreFiles(filename)) {
if (await this.plugin.isIgnoredByIgnoreFiles(filename)) {
return;
}
return await runWithLock("file-" + prefixedFileName, false, async () => {
@@ -568,7 +568,7 @@ export class HiddenFileSync extends LiveSyncCommands {
await this.app.vault.adapter.remove(filename);
try {
//@ts-ignore internalAPI
await app.vault.adapter.reconcileInternalFile(filename);
await this.app.vault.adapter.reconcileInternalFile(filename);
} catch (ex) {
Logger("Failed to call internal API(reconcileInternalFile)", LOG_LEVEL_VERBOSE);
Logger(ex, LOG_LEVEL_VERBOSE);
@@ -581,7 +581,7 @@ export class HiddenFileSync extends LiveSyncCommands {
await this.app.vault.adapter.writeBinary(filename, base64ToArrayBuffer(fileOnDB.data), { mtime: fileOnDB.mtime, ctime: fileOnDB.ctime });
try {
//@ts-ignore internalAPI
await app.vault.adapter.reconcileInternalFile(filename);
await this.app.vault.adapter.reconcileInternalFile(filename);
} catch (ex) {
Logger("Failed to call internal API(reconcileInternalFile)", LOG_LEVEL_VERBOSE);
Logger(ex, LOG_LEVEL_VERBOSE);
@@ -591,14 +591,14 @@ export class HiddenFileSync extends LiveSyncCommands {
} else {
const contentBin = await this.app.vault.adapter.readBinary(filename);
const content = await arrayBufferToBase64(contentBin);
if (content == fileOnDB.data && !force) {
if (isDocContentSame(content, fileOnDB.data) && !force) {
// Logger(`STORAGE <-- DB:${filename}: skipped (hidden) Not changed`, LOG_LEVEL_VERBOSE);
return true;
}
await this.app.vault.adapter.writeBinary(filename, base64ToArrayBuffer(fileOnDB.data), { mtime: fileOnDB.mtime, ctime: fileOnDB.ctime });
try {
//@ts-ignore internalAPI
await app.vault.adapter.reconcileInternalFile(filename);
await this.app.vault.adapter.reconcileInternalFile(filename);
} catch (ex) {
Logger("Failed to call internal API(reconcileInternalFile)", LOG_LEVEL_VERBOSE);
Logger(ex, LOG_LEVEL_VERBOSE);
@@ -653,7 +653,7 @@ export class HiddenFileSync extends LiveSyncCommands {
await this.storeInternalFileToDatabase({ path: filename, ...stat }, true);
try {
//@ts-ignore internalAPI
await app.vault.adapter.reconcileInternalFile(filename);
await this.app.vault.adapter.reconcileInternalFile(filename);
} catch (ex) {
Logger("Failed to call internal API(reconcileInternalFile)", LOG_LEVEL_VERBOSE);
Logger(ex, LOG_LEVEL_VERBOSE);
@@ -691,7 +691,7 @@ export class HiddenFileSync extends LiveSyncCommands {
const result: InternalFileInfo[] = [];
for (const f of files) {
const w = await f;
if (!await this.plugin.isIgnoredByIgnoreFiles(w.path)) {
if (await this.plugin.isIgnoredByIgnoreFiles(w.path)) {
continue
}
result.push({
@@ -734,7 +734,7 @@ export class HiddenFileSync extends LiveSyncCommands {
if (ignoreFilter && ignoreFilter.some(e => v.match(e))) {
continue L1;
}
if (!await this.plugin.isIgnoredByIgnoreFiles(v)) {
if (await this.plugin.isIgnoredByIgnoreFiles(v)) {
continue L1;
}
files = files.concat(await this.getFiles(v, ignoreList, filter, ignoreFilter));

Submodule src/lib updated: 6efd115e0e...8872807f47

View File

@@ -2569,9 +2569,14 @@ Or if you are sure know what had been happened, we can unlock the database from
}
}
/**
* Check the file is ignored by the ignore files.
* @param file
* @returns true if the file should be ignored, false if the file should be processed.
*/
async isIgnoredByIgnoreFiles(file: string | TAbstractFile) {
if (!this.settings.useIgnoreFiles) {
return true;
return false;
}
const filepath = file instanceof TFile ? file.path : file as string;
if (this.ignoreFileCache.has(filepath)) {
@@ -2579,14 +2584,14 @@ Or if you are sure know what had been happened, we can unlock the database from
await this.readIgnoreFile(filepath);
}
if (!await isAcceptedAll(stripAllPrefixes(filepath as FilePathWithPrefix), this.ignoreFiles, (filename) => this.getIgnoreFile(filename))) {
return false;
return true;
}
return true;
return false;
}
async isTargetFile(file: string | TAbstractFile) {
const filepath = file instanceof TFile ? file.path : file as string;
if (this.settings.useIgnoreFiles && !await this.isIgnoredByIgnoreFiles(file)) {
if (this.settings.useIgnoreFiles && await this.isIgnoredByIgnoreFiles(file)) {
return false;
}
return this.localDatabase.isTargetFile(filepath);

View File

@@ -14,38 +14,7 @@ I hope you will give it a try.
#### Minors
- 0.19.1 to 0.19.11 has been moved into the updates_old.md
- 0.19.12
- Improved:
- Boot-up performance has been improved.
- Customisation sync performance has been improved.
- Synchronising performance has been improved.
- 0.19.13
- Implemented:
- Database clean-up is now in beta 2!
We can shrink the remote database by deleting unused chunks, with keeping history.
Note: Local database is not cleaned up totally. We have to `Fetch` again to let it done.
**Note2**: Still in beta. Please back your vault up anything before.
- Fixed:
- The log updates are not thinned out now.
- 0.19.14
- Fixed:
- Internal documents are now ignored.
- Merge dialogue now respond immediately to button pressing.
- Periodic processing now works fine.
- The checking interval of detecting conflicted has got shorter.
- Replication is now cancelled while cleaning up.
- The database locking by the cleaning up is now carefully unlocked.
- Missing chunks message is correctly reported.
- New feature:
- Suspend database reflecting has been implemented.
- This can be disabled by `Fetch database with previous behaviour`.
- Now fetch suspends the reflecting database and storage changes temporarily to improve the performance.
- We can choose the action when the remote database has been cleaned
- Merge dialogue now show `↲` before the new line.
- Improved:
- Now progress is reported while the cleaning up and fetch process.
- Cancelled replication is now detected.
- 0.19.1 to 0.19.14 has been moved into the updates_old.md
- 0.19.15
- Fixed:
- Now storing files after cleaning up is correct works.
@@ -67,5 +36,12 @@ I hope you will give it a try.
- Compiler, framework, and dependencies have been upgraded.
- Due to standing for these impacts (especially in esbuild and svelte,) terser has been introduced.
Feel free to notify your opinion to me! I do not like to obfuscate the code too.
- 0.19.17
- Fixed:
- Now nested ignore files could be parsed correctly.
- The unexpected deletion of hidden files in some cases has been corrected.
- Hidden file change is no longer reflected on the device which has made the change itself.
- Behaviour changed:
- From this version, the file which has `:` in its name should be ignored even if on Linux devices.
... To continue on to `updates_old.md`.

View File

@@ -82,6 +82,37 @@ I hope you will give it a try.
- Logging keeps 400 lines now.
- Refactored:
- Import statement has been fixed about types.
- 0.19.12
- Improved:
- Boot-up performance has been improved.
- Customisation sync performance has been improved.
- Synchronising performance has been improved.
- 0.19.13
- Implemented:
- Database clean-up is now in beta 2!
We can shrink the remote database by deleting unused chunks, with keeping history.
Note: Local database is not cleaned up totally. We have to `Fetch` again to let it done.
**Note2**: Still in beta. Please back your vault up anything before.
- Fixed:
- The log updates are not thinned out now.
- 0.19.14
- Fixed:
- Internal documents are now ignored.
- Merge dialogue now respond immediately to button pressing.
- Periodic processing now works fine.
- The checking interval of detecting conflicted has got shorter.
- Replication is now cancelled while cleaning up.
- The database locking by the cleaning up is now carefully unlocked.
- Missing chunks message is correctly reported.
- New feature:
- Suspend database reflecting has been implemented.
- This can be disabled by `Fetch database with previous behaviour`.
- Now fetch suspends the reflecting database and storage changes temporarily to improve the performance.
- We can choose the action when the remote database has been cleaned
- Merge dialogue now show `↲` before the new line.
- Improved:
- Now progress is reported while the cleaning up and fetch process.
- Cancelled replication is now detected.
### 0.18.0
#### Now, paths of files in the database can now be obfuscated. (Experimental Feature)