mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-03-05 17:38:48 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d61d6fec37 | ||
|
|
9fdd622824 | ||
|
|
3b8d03a189 | ||
|
|
d0e92cff7a | ||
|
|
5addddc792 | ||
|
|
d978892661 | ||
|
|
cfb061a6a2 | ||
|
|
381055fc93 | ||
|
|
37d12916fc |
65
README.md
65
README.md
@@ -1,35 +1,39 @@
|
||||
<!-- For translation: 20240227r0 -->
|
||||
# Self-hosted LiveSync
|
||||
[Japanese docs](./README_ja.md) - [Chinese docs](./README_cn.md).
|
||||
|
||||
Self-hosted LiveSync is a community-implemented synchronization plugin, available on every obsidian-compatible platform and using CouchDB or Object Storage (e.g., MinIO, S3, R2, etc.) as the server.
|
||||
|
||||
Self-hosted LiveSync is a community-developed synchronisation plug-in available on all Obsidian-compatible platforms. It leverages robust server solutions such as CouchDB or object storage systems (e.g., MinIO, S3, R2, etc.) to ensure reliable data synchronisation.
|
||||
|
||||
Additionally, it supports peer-to-peer synchronisation using WebRTC now (experimental), enabling you to synchronise your notes directly between devices without relying on a server.
|
||||
|
||||

|
||||
|
||||
Note: This plugin cannot synchronise with the official "Obsidian Sync".
|
||||
>[!IMPORTANT]
|
||||
> This plug-in is not compatible with the official "Obsidian Sync" and cannot synchronise with it.
|
||||
|
||||
## Features
|
||||
- Synchronise vaults efficiently with minimal traffic.
|
||||
- Handle conflicting modifications effectively.
|
||||
- Automatically merge simple conflicts.
|
||||
- Use open-source solutions for the server.
|
||||
- Compatible solutions are supported.
|
||||
- Support end-to-end encryption.
|
||||
- Synchronise settings, snippets, themes, and plug-ins via [Customisation Sync (Beta)](#customization-sync) or [Hidden File Sync](#hiddenfilesync).
|
||||
- Enable WebRTC peer-to-peer synchronisation without requiring a `host` (Experimental).
|
||||
- This feature is still in the experimental stage. Please exercise caution when using it.
|
||||
- WebRTC is a peer-to-peer synchronisation method, so **at least one device must be online to synchronise**.
|
||||
- Instead of keeping your device online as a stable peer, you can use two pseudo-peers:
|
||||
- [livesync-serverpeer](https://github.com/vrtmrz/livesync-serverpeer): A pseudo-client running on the server for receiving and sending data between devices.
|
||||
- [webpeer](https://github.com/vrtmrz/livesync-commonlib/tree/main/apps/webpeer): A pseudo-client for receiving and sending data between devices.
|
||||
- A pre-built instance is available at [fancy-syncing.vrtmrz.net/webpeer](https://fancy-syncing.vrtmrz.net/webpeer/) (hosted on the vrtmrz blog site). This is also peer-to-peer. Feel free to use it.
|
||||
- For more information, refer to the [English explanatory article](https://fancy-syncing.vrtmrz.net/blog/0034-p2p-sync-en.html) or the [Japanese explanatory article](https://fancy-syncing.vrtmrz.net/blog/0034-p2p-sync).
|
||||
|
||||
- Synchronize vaults very efficiently with less traffic.
|
||||
- Good at conflicted modification.
|
||||
- Automatic merging for simple conflicts.
|
||||
- Using OSS solution for the server.
|
||||
- Compatible solutions can be used.
|
||||
- Supporting End-to-end encryption.
|
||||
- Synchronisation of settings, snippets, themes, and plug-ins, via [Customization sync(Beta)](#customization-sync) or [Hidden File Sync](#hiddenfilesync)
|
||||
- WebClip from [obsidian-livesync-webclip](https://chrome.google.com/webstore/detail/obsidian-livesync-webclip/jfpaflmpckblieefkegjncjoceapakdf)
|
||||
- WebRTC peer-to-peer synchronisation without the need for any `host` is now possible. (Experimental)
|
||||
- This feature is still in the experimental stage. Please be careful when using it.
|
||||
- Instead of using public servers, you can use [webpeer](https://github.com/vrtmrz/livesync-commonlib/tree/main/apps/webpeer) the pseudo client for receiving and sending between devices.
|
||||
- A pre-built instance is served at [fancy-syncing.vrtmrz.net/webpeer](https://fancy-syncing.vrtmrz.net/webpeer/) (in the vrtmrz blog site). This is of course also peer-to-peer. Feel free to use it.
|
||||
- There is an [English explanatory article](https://fancy-syncing.vrtmrz.net/blog/0034-p2p-sync-en.html), and [Japanese explanatory article](https://fancy-syncing.vrtmrz.net/blog/0034-p2p-sync).
|
||||
|
||||
This plug-in might be useful for researchers, engineers, and developers with a need to keep their notes fully self-hosted for security reasons. Or just anyone who would like the peace of mind of knowing that their notes are fully private.
|
||||
This plug-in may be particularly useful for researchers, engineers, and developers who need to keep their notes fully self-hosted for security reasons. It is also suitable for anyone seeking the peace of mind that comes with knowing their notes remain entirely private.
|
||||
|
||||
>[!IMPORTANT]
|
||||
> - Before installing or upgrading this plug-in, please back your vault up.
|
||||
> - Do not enable this plugin with another synchronization solution at the same time (including iCloud and Obsidian Sync).
|
||||
> - This is a synchronization plugin. Not a backup solution. Do not rely on this for backup.
|
||||
> - Before installing or upgrading this plug-in, please back up your vault.
|
||||
> - Do not enable this plug-in alongside another synchronisation solution at the same time (including iCloud and Obsidian Sync).
|
||||
> - For backups, we also provide a plug-in called [Differential ZIP Backup](https://github.com/vrtmrz/diffzip).
|
||||
|
||||
## How to use
|
||||
|
||||
@@ -48,9 +52,11 @@ This plug-in might be useful for researchers, engineers, and developers with a n
|
||||
1. [Setup CouchDB on fly.io](docs/setup_flyio.md)
|
||||
2. [Setup your CouchDB](docs/setup_own_server.md)
|
||||
2. Configure plug-in in [Quick Setup](docs/quick_setup.md)
|
||||
|
||||
> [!TIP]
|
||||
> Now, fly.io has become not free. Fortunately, even though there are some issues, we are still able to use IBM Cloudant. Here is [Setup IBM Cloudant](docs/setup_cloudant.md). It will be updated soon!
|
||||
> Fly.io is no longer free. Fortunately, despite some issues, we can still use IBM Cloudant. Refer to [Setup IBM Cloudant](docs/setup_cloudant.md).
|
||||
> And also, we can use peer-to-peer synchronisation without a server. Or very cheap Object Storage -- Cloudflare R2 can be used for free.
|
||||
> HOWEVER, most importantly, we can use the server that we trust. Therefore, please set up your own server.
|
||||
> CouchDB can be run on a Raspberry Pi. (But please be careful about the security of your server).
|
||||
|
||||
|
||||
## Information in StatusBar
|
||||
@@ -80,17 +86,14 @@ Synchronization status is shown in the status bar with the following icons.
|
||||
|
||||
To prevent file and database corruption, please wait to stop Obsidian until all progress indicators have disappeared as possible (The plugin will also try to resume, though). Especially in case of if you have deleted or renamed files.
|
||||
|
||||
|
||||
|
||||
## Tips and Troubleshooting
|
||||
If you are having problems getting the plugin working see: [Tips and Troubleshooting](docs/troubleshooting.md)
|
||||
If you are having problems getting the plugin working see: [Tips and Troubleshooting](docs/troubleshooting.md).
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
The project has been in continual progress and harmony because of
|
||||
- Many [Contributors](https://github.com/vrtmrz/obsidian-livesync/graphs/contributors)
|
||||
- Many [GitHub Sponsors](https://github.com/sponsors/vrtmrz#sponsors)
|
||||
- JetBrains Community Programs / Support for Open-Source Projects <img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.png" alt="JetBrains logo." height="24">
|
||||
The project has been in continual progress and harmony thanks to:
|
||||
- Many [Contributors](https://github.com/vrtmrz/obsidian-livesync/graphs/contributors).
|
||||
- Many [GitHub Sponsors](https://github.com/sponsors/vrtmrz#sponsors).
|
||||
- JetBrains Community Programs / Support for Open-Source Projects. <img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.png" alt="JetBrains logo" height="24">
|
||||
|
||||
May those who have contributed be honoured and remembered for their kindness and generosity.
|
||||
|
||||
|
||||
BIN
docs/all_toggles.png
Normal file
BIN
docs/all_toggles.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
@@ -1,8 +1,15 @@
|
||||
<!-- 2025-02-18 -->
|
||||
|
||||
# Tips and Troubleshooting
|
||||
|
||||
- [Tips and Troubleshooting](#tips-and-troubleshooting)
|
||||
- [Tips](#tips)
|
||||
- [CORS configuration with reverse proxy](#cors-configuration-with-reverse-proxy)
|
||||
- [Nginx](#nginx)
|
||||
- [Nginx and subdirectory](#nginx-and-subdirectory)
|
||||
- [Caddy](#caddy)
|
||||
- [Caddy and subdirectory](#caddy-and-subdirectory)
|
||||
- [Apache](#apache)
|
||||
- [Show all setting panes](#show-all-setting-panes)
|
||||
- [How to resolve `Tweaks Mismatched of Changed`](#how-to-resolve-tweaks-mismatched-of-changed)
|
||||
- [Notable bugs and fixes](#notable-bugs-and-fixes)
|
||||
- [Binary files get bigger on iOS](#binary-files-get-bigger-on-ios)
|
||||
- [Some setting name has been changed](#some-setting-name-has-been-changed)
|
||||
@@ -17,21 +24,130 @@
|
||||
- [How can I use the DevTools?](#how-can-i-use-the-devtools)
|
||||
- [Checking the network log](#checking-the-network-log)
|
||||
- [Troubleshooting](#troubleshooting)
|
||||
- [While using Cloudflare Tunnels, often Obsidian API fallback and `524` error occurs.](#while-using-cloudflare-tunnels-often-obsidian-api-fallback-and-524-error-occurs)
|
||||
- [On the mobile device, cannot synchronise on the local network!](#on-the-mobile-device-cannot-synchronise-on-the-local-network)
|
||||
- [I think that something bad happening on the vault...](#i-think-that-something-bad-happening-on-the-vault)
|
||||
- [Tips](#tips)
|
||||
- [How to resolve `Tweaks Mismatched of Changed`](#how-to-resolve-tweaks-mismatched-of-changed)
|
||||
- [Old tips](#old-tips)
|
||||
|
||||
<!-- - -->
|
||||
|
||||
## Tips
|
||||
|
||||
### CORS configuration with reverse proxy
|
||||
|
||||
- IMPORTANT: CouchDB handles CORS by itself. Do not process CORS on the reverse
|
||||
proxy.
|
||||
- Do not process `Option` requests on the reverse proxy!
|
||||
- Make sure `host` and `X-Forwarded-For` headers are forwarded to the CouchDB.
|
||||
- If you are using a subdirectory, make sure to handle it properly. More
|
||||
detailed information is in the
|
||||
[CouchDB documentation](https://docs.couchdb.org/en/stable/best-practices/reverse-proxies.html).
|
||||
|
||||
Minimal configurations are as follows:
|
||||
|
||||
#### Nginx
|
||||
|
||||
```nginx
|
||||
location / {
|
||||
proxy_pass http://localhost:5984;
|
||||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
```
|
||||
|
||||
#### Nginx and subdirectory
|
||||
|
||||
```nginx
|
||||
location /couchdb {
|
||||
rewrite ^ $request_uri;
|
||||
rewrite ^/couchdb/(.*) /$1 break;
|
||||
proxy_pass http://localhost:5984$uri;
|
||||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
location /_session {
|
||||
proxy_pass http://localhost:5984/_session;
|
||||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
```
|
||||
|
||||
#### Caddy
|
||||
|
||||
```caddyfile
|
||||
domain.com {
|
||||
reverse_proxy localhost:5984
|
||||
}
|
||||
```
|
||||
|
||||
#### Caddy and subdirectory
|
||||
|
||||
```caddyfile
|
||||
domain.com {
|
||||
reverse_proxy /couchdb/* localhost:5984
|
||||
reverse_proxy /_session/* localhost:5984/_session
|
||||
}
|
||||
```
|
||||
|
||||
#### Apache
|
||||
|
||||
Sorry, Apache is not recommended for CouchDB. Omit the configuration from here.
|
||||
Please refer to the
|
||||
[Official documentation](https://docs.couchdb.org/en/stable/best-practices/reverse-proxies.html#reverse-proxying-with-apache-http-server).
|
||||
|
||||
### Show all setting panes
|
||||
|
||||
Full pane is not shown by default. To show all panes, please toggle all in
|
||||
`🧙♂️ Wizard` -> `Enable extra and advanced features`.
|
||||
|
||||
For your information, the all panes are as follows:
|
||||

|
||||
|
||||
### How to resolve `Tweaks Mismatched of Changed`
|
||||
|
||||
(Since v0.23.17)
|
||||
|
||||
If you have changed some configurations or tweaks which should be unified
|
||||
between the devices, you will be asked how to reflect (or not) other devices at
|
||||
the next synchronisation. It also occurs on the device itself, where changes are
|
||||
made, to prevent unexpected configuration changes from unwanted propagation.\
|
||||
(We may thank this behaviour if we have synchronised or backed up and restored
|
||||
Self-hosted LiveSync. At least, for me so).
|
||||
|
||||
Following dialogue will be shown: 
|
||||
|
||||
- If we want to propagate the setting of the device, we should choose
|
||||
`Update with mine`.
|
||||
- On other devices, we should choose `Use configured` to accept and use the
|
||||
configured configuration.
|
||||
- `Dismiss` can postpone a decision. However, we cannot synchronise until we
|
||||
have decided.
|
||||
|
||||
Rest assured that in most cases we can choose `Use configured`. (Unless you are
|
||||
certain that you have not changed the configuration).
|
||||
|
||||
If we see it for the first time, it reflects the settings of the device that has
|
||||
been synchronised with the remote for the first time since the upgrade.
|
||||
Probably, we can accept that.
|
||||
|
||||
<!-- Add here -->
|
||||
|
||||
## Notable bugs and fixes
|
||||
|
||||
### Binary files get bigger on iOS
|
||||
|
||||
- Reported at: v0.20.x
|
||||
- Fixed at: v0.21.2 (Fixed but not reviewed)
|
||||
- Required action: larger files will not be fixed automatically, please perform `Verify and repair all files`. If our local database and storage are not matched, we will be asked to apply which one.
|
||||
- Required action: larger files will not be fixed automatically, please perform
|
||||
`Verify and repair all files`. If our local database and storage are not
|
||||
matched, we will be asked to apply which one.
|
||||
|
||||
### Some setting name has been changed
|
||||
|
||||
@@ -48,39 +164,50 @@
|
||||
|
||||
### Why `Use an old adapter for compatibility` is somehow enabled in my vault?
|
||||
|
||||
Because you are a compassionate and experienced user. Before v0.17.16, we used an old adapter for the local database. At that time, current default adapter has not been stable.
|
||||
The new adapter has better performance and has a new feature like purging. Therefore, we should use new adapters and current default is so.
|
||||
Because you are a compassionate and experienced user. Before v0.17.16, we used
|
||||
an old adapter for the local database. At that time, current default adapter has
|
||||
not been stable. The new adapter has better performance and has a new feature
|
||||
like purging. Therefore, we should use new adapters and current default is so.
|
||||
|
||||
However, when switching from an old adapter to a new adapter, some converting or local database rebuilding is required, and it takes a few time. It was a long time ago now, but we once inconvenienced everyone in a hurry when we changed the format of our database.
|
||||
For these reasons, this toggle is automatically on if we have upgraded from vault which using an old adapter.
|
||||
However, when switching from an old adapter to a new adapter, some converting or
|
||||
local database rebuilding is required, and it takes a few time. It was a long
|
||||
time ago now, but we once inconvenienced everyone in a hurry when we changed the
|
||||
format of our database. For these reasons, this toggle is automatically on if we
|
||||
have upgraded from vault which using an old adapter.
|
||||
|
||||
When you rebuild everything or fetch from the remote again, you will be asked to switch this.
|
||||
When you rebuild everything or fetch from the remote again, you will be asked to
|
||||
switch this.
|
||||
|
||||
Therefore, experienced users (especially those stable enough not to have to rebuild the database) may have this toggle enabled in their Vault.
|
||||
Please disable it when you have enough time.
|
||||
Therefore, experienced users (especially those stable enough not to have to
|
||||
rebuild the database) may have this toggle enabled in their Vault. Please
|
||||
disable it when you have enough time.
|
||||
|
||||
### ZIP (or any extensions) files were not synchronised. Why?
|
||||
|
||||
It depends on Obsidian detects. May toggling `Detect all extensions` of `File and links` (setting of Obsidian) will help us.
|
||||
It depends on Obsidian detects. May toggling `Detect all extensions` of
|
||||
`File and links` (setting of Obsidian) will help us.
|
||||
|
||||
### I hope to report the issue, but you said you needs `Report`. How to make it?
|
||||
|
||||
We can copy the report to the clipboard, by pressing the `Make report` button on the `Hatch` pane.
|
||||

|
||||
We can copy the report to the clipboard, by pressing the `Make report` button on
|
||||
the `Hatch` pane. 
|
||||
|
||||
### Where can I check the log?
|
||||
|
||||
We can launch the log pane by `Show log` on the command palette.
|
||||
And if you have troubled something, please enable the `Verbose Log` on the `General Setting` pane.
|
||||
We can launch the log pane by `Show log` on the command palette. And if you have
|
||||
troubled something, please enable the `Verbose Log` on the `General Setting`
|
||||
pane.
|
||||
|
||||
However, the logs would not be kept so long and cleared when restarted. If you want to check the logs, please enable `Write logs into the file` temporarily.
|
||||
However, the logs would not be kept so long and cleared when restarted. If you
|
||||
want to check the logs, please enable `Write logs into the file` temporarily.
|
||||
|
||||

|
||||
|
||||
> [!IMPORTANT]
|
||||
>
|
||||
> - Writing logs into the file will impact the performance.
|
||||
> - Please make sure that you have erased all your confidential information before reporting issue.
|
||||
> - Please make sure that you have erased all your confidential information
|
||||
> before reporting issue.
|
||||
|
||||
### Why are the logs volatile and ephemeral?
|
||||
|
||||
@@ -88,41 +215,76 @@ To avoid unexpected exposure to our confidential things.
|
||||
|
||||
### Some network logs are not written into the file.
|
||||
|
||||
Especially the CORS error will be reported as a general error to the plug-in for security reasons. So we cannot detect and log it. We are only able to investigate them by [Checking the network log](#checking-the-network-log).
|
||||
Especially the CORS error will be reported as a general error to the plug-in for
|
||||
security reasons. So we cannot detect and log it. We are only able to
|
||||
investigate them by [Checking the network log](#checking-the-network-log).
|
||||
|
||||
### If a file were deleted or trimmed, the capacity of the database should be reduced, right?
|
||||
|
||||
No, even though if files were deleted, chunks were not deleted.
|
||||
Self-hosted LiveSync splits the files into multiple chunks and transfers only newly created. This behaviour enables us to less traffic. And, the chunks will be shared between the files to reduce the total usage of the database.
|
||||
No, even though if files were deleted, chunks were not deleted. Self-hosted
|
||||
LiveSync splits the files into multiple chunks and transfers only newly created.
|
||||
This behaviour enables us to less traffic. And, the chunks will be shared
|
||||
between the files to reduce the total usage of the database.
|
||||
|
||||
And one more thing, we can handle the conflicts on any device even though it has happened on other devices. This means that conflicts will happen in the past, after the time we have synchronised. Hence we cannot collect and delete the unused chunks even though if we are not currently referenced.
|
||||
And one more thing, we can handle the conflicts on any device even though it has
|
||||
happened on other devices. This means that conflicts will happen in the past,
|
||||
after the time we have synchronised. Hence we cannot collect and delete the
|
||||
unused chunks even though if we are not currently referenced.
|
||||
|
||||
To shrink the database size, `Rebuild everything` only reliably and effectively. But do not worry, if we have synchronised well. We have the actual and real files. Only it takes a bit of time and traffics.
|
||||
To shrink the database size, `Rebuild everything` only reliably and effectively.
|
||||
But do not worry, if we have synchronised well. We have the actual and real
|
||||
files. Only it takes a bit of time and traffics.
|
||||
|
||||
### How can I use the DevTools?
|
||||
|
||||
#### Checking the network log
|
||||
|
||||
1. Open the network pane.
|
||||
2. Find the requests marked in red.
|
||||
2. Find the requests marked in red.\
|
||||

|
||||
3. Capture the `Headers`, `Payload`, and, `Response`. **Please be sure to keep important information confidential**. If the `Response` contains secrets, you can omitted that.
|
||||
Note: Headers contains a some credentials. **The path of the request URL, Remote Address, authority, and authorization must be concealed.**
|
||||
3. Capture the `Headers`, `Payload`, and, `Response`. **Please be sure to keep
|
||||
important information confidential**. If the `Response` contains secrets, you
|
||||
can omitted that. Note: Headers contains a some credentials. **The path of
|
||||
the request URL, Remote Address, authority, and authorization must be
|
||||
concealed.**\
|
||||

|
||||
|
||||
## Troubleshooting
|
||||
|
||||
<!-- Add here -->
|
||||
|
||||
### While using Cloudflare Tunnels, often Obsidian API fallback and `524` error occurs.
|
||||
|
||||
A `524` error occurs when the request to the server is not completed within a
|
||||
`specified time`. This is a timeout error from Cloudflare. From the reported
|
||||
issue, it seems to be 100 seconds. (#627).
|
||||
|
||||
Therefore, this error returns from Cloudflare, not from the server. Hence, the
|
||||
result contains no CORS field. It means that this response makes the Obsidian
|
||||
API fallback.
|
||||
|
||||
However, even if the Obsidian API fallback occurs, the request is still not
|
||||
completed within the `specified time`, 100 seconds.
|
||||
|
||||
To solve this issue, we need to configure the timeout settings.
|
||||
|
||||
Please enable the toggle in `💪 Power users` -> `CouchDB Connection Tweak` ->
|
||||
`Use timeouts instead of heartbeats`.
|
||||
|
||||
### On the mobile device, cannot synchronise on the local network!
|
||||
|
||||
Obsidian mobile is not able to connect to the non-secure end-point, such as starting with `http://`. Make sure your URI of CouchDB. Also not able to use a self-signed certificate.
|
||||
Obsidian mobile is not able to connect to the non-secure end-point, such as
|
||||
starting with `http://`. Make sure your URI of CouchDB. Also not able to use a
|
||||
self-signed certificate.
|
||||
|
||||
### I think that something bad happening on the vault...
|
||||
|
||||
Place `redflag.md` on top of the vault, and restart Obsidian. The most simple way is to create a new note and rename it to `redflag`. Of course, we can put it without Obsidian.
|
||||
Place `redflag.md` on top of the vault, and restart Obsidian. The most simple
|
||||
way is to create a new note and rename it to `redflag`. Of course, we can put it
|
||||
without Obsidian.
|
||||
|
||||
If there is `redflag.md`, Self-hosted LiveSync suspends all database and storage processes.
|
||||
If there is `redflag.md`, Self-hosted LiveSync suspends all database and storage
|
||||
processes.
|
||||
|
||||
There are some options to use `redflag.md`.
|
||||
|
||||
@@ -132,44 +294,48 @@ There are some options to use `redflag.md`.
|
||||
| `redflag2.md` | `flag_rebuild.md` | Suspends all processes, and rebuild both local and remote databases by local files. |
|
||||
| `redflag3.md` | `flag_fetch.md` | Suspends all processes, discard the local database, and fetch from the remote again. |
|
||||
|
||||
When fetching everything remotely or performing a rebuild, restarting Obsidian is performed once for safety reasons. At that time, Self-hosted LiveSync uses these files to determine whether the process should be carried out.
|
||||
(The use of normal markdown files is a trick to externally force cancellation in the event of faults in the rebuild or fetch function itself, especially on mobile devices).
|
||||
This mechanism is also used for set-up. And just for information, these files are also not subject to synchronisation.
|
||||
When fetching everything remotely or performing a rebuild, restarting Obsidian
|
||||
is performed once for safety reasons. At that time, Self-hosted LiveSync uses
|
||||
these files to determine whether the process should be carried out. (The use of
|
||||
normal markdown files is a trick to externally force cancellation in the event
|
||||
of faults in the rebuild or fetch function itself, especially on mobile
|
||||
devices). This mechanism is also used for set-up. And just for information,
|
||||
these files are also not subject to synchronisation.
|
||||
|
||||
However, occasionally the deletion of files may fail. This should generally work normally after restarting Obsidian. (As far as I can observe).
|
||||
|
||||
## Tips
|
||||
|
||||
### How to resolve `Tweaks Mismatched of Changed`
|
||||
|
||||
(Since v0.23.17)
|
||||
|
||||
If you have changed some configurations or tweaks which should be unified between the devices, you will be asked how to reflect (or not) other devices at the next synchronisation. It also occurs on the device itself, where changes are made, to prevent unexpected configuration changes from unwanted propagation.
|
||||
(We may thank this behaviour if we have synchronised or backed up and restored Self-hosted LiveSync. At least, for me so).
|
||||
|
||||
Following dialogue will be shown:
|
||||

|
||||
|
||||
- If we want to propagate the setting of the device, we should choose `Update with mine`.
|
||||
- On other devices, we should choose `Use configured` to accept and use the configured configuration.
|
||||
- `Dismiss` can postpone a decision. However, we cannot synchronise until we have decided.
|
||||
|
||||
Rest assured that in most cases we can choose `Use configured`. (Unless you are certain that you have not changed the configuration).
|
||||
|
||||
If we see it for the first time, it reflects the settings of the device that has been synchronised with the remote for the first time since the upgrade. Probably, we can accept that.
|
||||
|
||||
<!-- Add here -->
|
||||
However, occasionally the deletion of files may fail. This should generally work
|
||||
normally after restarting Obsidian. (As far as I can observe).
|
||||
|
||||
### Old tips
|
||||
|
||||
- Rarely, a file in the database could be corrupted. The plugin will not write to local storage when a file looks corrupted. If a local version of the file is on your device, the corruption could be fixed by editing the local file and synchronizing it. But if the file does not exist on any of your devices, then it can not be rescued. In this case, you can delete these items from the settings dialog.
|
||||
- To stop the boot-up sequence (eg. for fixing problems on databases), you can put a `redflag.md` file (or directory) at the root of your vault.
|
||||
Tip for iOS: a redflag directory can be created at the root of the vault using the File application.
|
||||
- Also, with `redflag2.md` placed, we can automatically rebuild both the local and the remote databases during the boot-up sequence. With `redflag3.md`, we can discard only the local database and fetch from the remote again.
|
||||
- Q: The database is growing, how can I shrink it down?
|
||||
A: each of the docs is saved with their past 100 revisions for detecting and resolving conflicts. Picturing that one device has been offline for a while, and comes online again. The device has to compare its notes with the remotely saved ones. If there exists a historic revision in which the note used to be identical, it could be updated safely (like git fast-forward). Even if that is not in revision histories, we only have to check the differences after the revision that both devices commonly have. This is like git's conflict-resolving method. So, We have to make the database again like an enlarged git repo if you want to solve the root of the problem.
|
||||
- Rarely, a file in the database could be corrupted. The plugin will not write
|
||||
to local storage when a file looks corrupted. If a local version of the file
|
||||
is on your device, the corruption could be fixed by editing the local file and
|
||||
synchronizing it. But if the file does not exist on any of your devices, then
|
||||
it can not be rescued. In this case, you can delete these items from the
|
||||
settings dialog.
|
||||
- To stop the boot-up sequence (eg. for fixing problems on databases), you can
|
||||
put a `redflag.md` file (or directory) at the root of your vault. Tip for iOS:
|
||||
a redflag directory can be created at the root of the vault using the File
|
||||
application.
|
||||
- Also, with `redflag2.md` placed, we can automatically rebuild both the local
|
||||
and the remote databases during the boot-up sequence. With `redflag3.md`, we
|
||||
can discard only the local database and fetch from the remote again.
|
||||
- Q: The database is growing, how can I shrink it down? A: each of the docs is
|
||||
saved with their past 100 revisions for detecting and resolving conflicts.
|
||||
Picturing that one device has been offline for a while, and comes online
|
||||
again. The device has to compare its notes with the remotely saved ones. If
|
||||
there exists a historic revision in which the note used to be identical, it
|
||||
could be updated safely (like git fast-forward). Even if that is not in
|
||||
revision histories, we only have to check the differences after the revision
|
||||
that both devices commonly have. This is like git's conflict-resolving method.
|
||||
So, We have to make the database again like an enlarged git repo if you want
|
||||
to solve the root of the problem.
|
||||
- And more technical Information is in the [Technical Information](tech_info.md)
|
||||
- If you want to synchronize files without obsidian, you can use [filesystem-livesync](https://github.com/vrtmrz/filesystem-livesync).
|
||||
- WebClipper is also available on Chrome Web Store:[obsidian-livesync-webclip](https://chrome.google.com/webstore/detail/obsidian-livesync-webclip/jfpaflmpckblieefkegjncjoceapakdf)
|
||||
- If you want to synchronize files without obsidian, you can use
|
||||
[filesystem-livesync](https://github.com/vrtmrz/filesystem-livesync).
|
||||
- WebClipper is also available on Chrome Web
|
||||
Store:[obsidian-livesync-webclip](https://chrome.google.com/webstore/detail/obsidian-livesync-webclip/jfpaflmpckblieefkegjncjoceapakdf)
|
||||
|
||||
Repo is here: [obsidian-livesync-webclip](https://github.com/vrtmrz/obsidian-livesync-webclip). (Docs are a work in progress.)
|
||||
Repo is here:
|
||||
[obsidian-livesync-webclip](https://github.com/vrtmrz/obsidian-livesync-webclip).
|
||||
(Docs are a work in progress.)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-livesync",
|
||||
"name": "Self-hosted LiveSync",
|
||||
"version": "0.24.24",
|
||||
"version": "0.24.26",
|
||||
"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",
|
||||
|
||||
5217
package-lock.json
generated
5217
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
48
package.json
48
package.json
@@ -1,13 +1,15 @@
|
||||
{
|
||||
"name": "obsidian-livesync",
|
||||
"version": "0.24.24",
|
||||
"version": "0.24.26",
|
||||
"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",
|
||||
"scripts": {
|
||||
"bakei18n": "npx tsx ./src/lib/_tools/bakei18n.ts",
|
||||
"postbakei18n": "prettier --config ./.prettierrc ./src/lib/src/common/messages/*.ts --write --log-level error",
|
||||
"dev": "node esbuild.config.mjs",
|
||||
"build": "npm run bakei18n && node esbuild.config.mjs production",
|
||||
"prebuild": "npm run bakei18n",
|
||||
"build": "node esbuild.config.mjs production",
|
||||
"buildDev": "node esbuild.config.mjs dev",
|
||||
"lint": "eslint src",
|
||||
"svelte-check": "svelte-check --tsconfig ./tsconfig.json",
|
||||
@@ -22,12 +24,12 @@
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@chialab/esbuild-plugin-worker": "^0.18.1",
|
||||
"@eslint/compat": "^1.2.6",
|
||||
"@eslint/eslintrc": "^3.2.0",
|
||||
"@eslint/js": "^9.20.0",
|
||||
"@eslint/compat": "^1.2.7",
|
||||
"@eslint/eslintrc": "^3.3.0",
|
||||
"@eslint/js": "^9.21.0",
|
||||
"@tsconfig/svelte": "^5.0.4",
|
||||
"@types/diff-match-patch": "^1.0.36",
|
||||
"@types/node": "^22.5.4",
|
||||
"@types/node": "^22.13.8",
|
||||
"@types/pouchdb": "^6.4.2",
|
||||
"@types/pouchdb-adapter-http": "^6.1.6",
|
||||
"@types/pouchdb-adapter-idb": "^6.1.7",
|
||||
@@ -36,17 +38,17 @@
|
||||
"@types/pouchdb-mapreduce": "^6.1.10",
|
||||
"@types/pouchdb-replication": "^6.4.7",
|
||||
"@types/transform-pouch": "^1.0.6",
|
||||
"@typescript-eslint/eslint-plugin": "^8.24.1",
|
||||
"@typescript-eslint/parser": "^8.24.1",
|
||||
"builtin-modules": "^4.0.0",
|
||||
"esbuild": "0.24.2",
|
||||
"@typescript-eslint/eslint-plugin": "8.25.0",
|
||||
"@typescript-eslint/parser": "8.25.0",
|
||||
"builtin-modules": "5.0.0",
|
||||
"esbuild": "0.25.0",
|
||||
"esbuild-svelte": "^0.9.0",
|
||||
"eslint": "^9.20.1",
|
||||
"eslint": "^9.21.0",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-svelte": "^2.46.1",
|
||||
"eslint-plugin-svelte": "^3.0.2",
|
||||
"events": "^3.3.0",
|
||||
"obsidian": "^1.7.2",
|
||||
"postcss": "^8.5.2",
|
||||
"obsidian": "^1.8.7",
|
||||
"postcss": "^8.5.3",
|
||||
"postcss-load-config": "^6.0.1",
|
||||
"pouchdb-adapter-http": "^9.0.0",
|
||||
"pouchdb-adapter-idb": "^9.0.0",
|
||||
@@ -58,29 +60,31 @@
|
||||
"pouchdb-merge": "^9.0.0",
|
||||
"pouchdb-replication": "^9.0.0",
|
||||
"pouchdb-utils": "^9.0.0",
|
||||
"prettier": "^3.5.1",
|
||||
"svelte": "^5.20.1",
|
||||
"prettier": "3.5.2",
|
||||
"svelte": "5.28.6",
|
||||
"svelte-preprocess": "^6.0.3",
|
||||
"terser": "^5.39.0",
|
||||
"transform-pouch": "^2.0.0",
|
||||
"tslib": "^2.8.1",
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "^5.7.3"
|
||||
"tsx": "^4.19.4",
|
||||
"typescript": "5.7.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.787.0",
|
||||
"@aws-sdk/client-s3": "^3.808.0",
|
||||
"@smithy/md5-js": "^4.0.2",
|
||||
"@smithy/middleware-apply-body-checksum": "^4.1.0",
|
||||
"@smithy/fetch-http-handler": "^5.0.2",
|
||||
"@smithy/protocol-http": "^5.1.0",
|
||||
"@smithy/querystring-builder": "^4.0.2",
|
||||
"diff-match-patch": "^1.0.5",
|
||||
"esbuild-plugin-inline-worker": "^0.1.1",
|
||||
"fflate": "^0.8.2",
|
||||
"idb": "^8.0.2",
|
||||
"idb": "^8.0.3",
|
||||
"minimatch": "^10.0.1",
|
||||
"octagonal-wheels": "^0.1.25",
|
||||
"qrcode-generator": "^1.4.4",
|
||||
"svelte-check": "^4.1.4",
|
||||
"trystero": "^0.21.1",
|
||||
"svelte-check": "^4.1.7",
|
||||
"trystero": "^0.21.3",
|
||||
"xxhash-wasm-102": "npm:xxhash-wasm@^1.0.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,10 +613,10 @@ const decodePrefixMapNumber = Object.fromEntries(
|
||||
);
|
||||
export function encodeAnyArray(obj: any[]): string {
|
||||
const tempArray = obj.map((v) => {
|
||||
if (v == null) return "n";
|
||||
if (v == false) return "f";
|
||||
if (v == true) return "t";
|
||||
if (v == undefined) return "u";
|
||||
if (v === null) return "n";
|
||||
if (v === false) return "f";
|
||||
if (v === true) return "t";
|
||||
if (v === undefined) return "u";
|
||||
if (typeof v == "number") {
|
||||
const b36 = v.toString(36);
|
||||
const strNum = v.toString();
|
||||
|
||||
@@ -25,6 +25,8 @@ import {
|
||||
readContent,
|
||||
createBlob,
|
||||
fireAndForget,
|
||||
type CustomRegExp,
|
||||
getFileRegExp,
|
||||
} from "../../lib/src/common/utils.ts";
|
||||
import {
|
||||
compareMTime,
|
||||
@@ -164,12 +166,11 @@ export class HiddenFileSync extends LiveSyncCommands implements IObsidianModule
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
updateSettingCache() {
|
||||
const ignorePatterns = this.settings.syncInternalFilesIgnorePatterns
|
||||
.replace(/\n| /g, "")
|
||||
.split(",")
|
||||
.filter((e) => e)
|
||||
.map((e) => new RegExp(e, "i"));
|
||||
const ignorePatterns = getFileRegExp(this.plugin.settings, "syncInternalFilesIgnorePatterns");
|
||||
this.ignorePatterns = ignorePatterns;
|
||||
const targetFilter = getFileRegExp(this.plugin.settings, "syncInternalFilesTargetPatterns");
|
||||
this.targetPatterns = targetFilter;
|
||||
|
||||
this.shouldSkipFile = [] as FilePathWithPrefixLC[];
|
||||
// Exclude files handled by customization sync
|
||||
const configDir = normalizePath(this.app.vault.configDir);
|
||||
@@ -219,12 +220,10 @@ export class HiddenFileSync extends LiveSyncCommands implements IObsidianModule
|
||||
? this.settings.syncInternalFilesInterval * 1000
|
||||
: 0
|
||||
);
|
||||
const ignorePatterns = this.settings.syncInternalFilesIgnorePatterns
|
||||
.replace(/\n| /g, "")
|
||||
.split(",")
|
||||
.filter((e) => e)
|
||||
.map((e) => new RegExp(e, "i"));
|
||||
const ignorePatterns = getFileRegExp(this.plugin.settings, "syncInternalFilesIgnorePatterns");
|
||||
this.ignorePatterns = ignorePatterns;
|
||||
const targetFilter = getFileRegExp(this.plugin.settings, "syncInternalFilesTargetPatterns");
|
||||
this.targetPatterns = targetFilter;
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
@@ -1683,14 +1682,12 @@ ${messageFetch}${messageOverwrite}${messageMerge}
|
||||
// <-- Configuration handling
|
||||
|
||||
// --> Local Storage SubFunctions
|
||||
ignorePatterns: RegExp[] = [];
|
||||
ignorePatterns: CustomRegExp[] = [];
|
||||
targetPatterns: CustomRegExp[] = [];
|
||||
async scanInternalFileNames() {
|
||||
const configDir = normalizePath(this.app.vault.configDir);
|
||||
const ignoreFilter = this.settings.syncInternalFilesIgnorePatterns
|
||||
.replace(/\n| /g, "")
|
||||
.split(",")
|
||||
.filter((e) => e)
|
||||
.map((e) => new RegExp(e, "i"));
|
||||
const ignoreFilter = getFileRegExp(this.plugin.settings, "syncInternalFilesIgnorePatterns");
|
||||
const targetFilter = getFileRegExp(this.plugin.settings, "syncInternalFilesTargetPatterns");
|
||||
const synchronisedInConfigSync = !this.settings.usePluginSync
|
||||
? []
|
||||
: Object.values(this.settings.pluginSyncExtendedSetting)
|
||||
@@ -1701,7 +1698,7 @@ ${messageFetch}${messageOverwrite}${messageMerge}
|
||||
const root = this.app.vault.getRoot();
|
||||
const findRoot = root.path;
|
||||
|
||||
const filenames = (await this.getFiles(findRoot, [], undefined, ignoreFilter))
|
||||
const filenames = (await this.getFiles(findRoot, [], targetFilter, ignoreFilter))
|
||||
.filter((e) => e.startsWith("."))
|
||||
.filter((e) => !e.startsWith(".trash"));
|
||||
const files = filenames.filter((path) =>
|
||||
@@ -1737,7 +1734,7 @@ ${messageFetch}${messageOverwrite}${messageMerge}
|
||||
return result;
|
||||
}
|
||||
|
||||
async getFiles(path: string, ignoreList: string[], filter?: RegExp[], ignoreFilter?: RegExp[]) {
|
||||
async getFiles(path: string, ignoreList: string[], filter?: CustomRegExp[], ignoreFilter?: CustomRegExp[]) {
|
||||
let w: ListedFiles;
|
||||
try {
|
||||
w = await this.app.vault.adapter.list(path);
|
||||
@@ -1746,26 +1743,32 @@ ${messageFetch}${messageOverwrite}${messageMerge}
|
||||
this._log(ex, LOG_LEVEL_VERBOSE);
|
||||
return [];
|
||||
}
|
||||
const filesSrc = [
|
||||
...w.files
|
||||
.filter((e) => !ignoreList.some((ee) => e.endsWith(ee)))
|
||||
.filter((e) => !filter || filter.some((ee) => e.match(ee)))
|
||||
.filter((e) => !ignoreFilter || ignoreFilter.every((ee) => !e.match(ee))),
|
||||
];
|
||||
let files = [] as string[];
|
||||
for (const file of filesSrc) {
|
||||
if (!(await this.plugin.$$isIgnoredByIgnoreFiles(file))) {
|
||||
files.push(file);
|
||||
for (const file of w.files) {
|
||||
if (ignoreList && ignoreList.length > 0) {
|
||||
if (ignoreList.some((e) => file.endsWith(e))) continue;
|
||||
}
|
||||
if (filter && filter.length > 0) {
|
||||
if (!filter.some((e) => e.test(file))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (ignoreFilter && ignoreFilter.some((ee) => ee.test(file))) {
|
||||
continue;
|
||||
}
|
||||
if (await this.plugin.$$isIgnoredByIgnoreFiles(file)) continue;
|
||||
files.push(file);
|
||||
}
|
||||
|
||||
L1: for (const v of w.folders) {
|
||||
for (const ignore of ignoreList) {
|
||||
if (v.endsWith(ignore)) {
|
||||
continue L1;
|
||||
}
|
||||
}
|
||||
if (ignoreFilter && ignoreFilter.some((e) => v.match(e))) {
|
||||
if (
|
||||
ignoreFilter &&
|
||||
ignoreFilter.some((e) => (e.pattern.startsWith("/") || e.pattern.startsWith("\\/")) && e.test(v))
|
||||
) {
|
||||
continue L1;
|
||||
}
|
||||
if (await this.plugin.$$isIgnoredByIgnoreFiles(v)) {
|
||||
|
||||
2
src/lib
2
src/lib
Submodule src/lib updated: be13c18ec1...d53cad1c68
@@ -291,7 +291,8 @@ export default class ObsidianLiveSyncPlugin
|
||||
performSetup: boolean,
|
||||
skipInfo: boolean,
|
||||
compression: boolean,
|
||||
customHeaders: Record<string, string>
|
||||
customHeaders: Record<string, string>,
|
||||
useRequestAPI: boolean
|
||||
): Promise<
|
||||
| string
|
||||
| {
|
||||
|
||||
@@ -14,7 +14,7 @@ import type {
|
||||
import { TFileToUXFileInfoStub, TFolderToUXFileInfoStub } from "./storageLib/utilObsidian.ts";
|
||||
import { StorageEventManagerObsidian, type StorageEventManager } from "./storageLib/StorageEventManager";
|
||||
import type { StorageAccess } from "../interfaces/StorageAccess";
|
||||
import { createBlob } from "../../lib/src/common/utils";
|
||||
import { createBlob, type CustomRegExp } from "../../lib/src/common/utils";
|
||||
|
||||
export class ModuleFileAccessObsidian extends AbstractObsidianModule implements IObsidianModule, StorageAccess {
|
||||
vaultAccess!: SerializedFileAccess;
|
||||
@@ -223,8 +223,8 @@ export class ModuleFileAccessObsidian extends AbstractObsidianModule implements
|
||||
|
||||
async getFilesIncludeHidden(
|
||||
basePath: string,
|
||||
includeFilter?: RegExp[],
|
||||
excludeFilter?: RegExp[],
|
||||
includeFilter?: CustomRegExp[],
|
||||
excludeFilter?: CustomRegExp[],
|
||||
skipFolder: string[] = [".git", ".trash", "node_modules"]
|
||||
): Promise<FilePath[]> {
|
||||
let w: ListedFiles;
|
||||
@@ -239,16 +239,11 @@ export class ModuleFileAccessObsidian extends AbstractObsidianModule implements
|
||||
|
||||
let files = [] as string[];
|
||||
for (const file of w.files) {
|
||||
if (excludeFilter && excludeFilter.some((ee) => file.match(ee))) {
|
||||
// If excludeFilter and includeFilter are both set, the file will be included in the list.
|
||||
if (includeFilter) {
|
||||
if (!includeFilter.some((e) => file.match(e))) continue;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if (includeFilter && includeFilter.length > 0) {
|
||||
if (!includeFilter.some((e) => e.test(file))) continue;
|
||||
}
|
||||
if (includeFilter) {
|
||||
if (!includeFilter.some((e) => file.match(e))) continue;
|
||||
if (excludeFilter && excludeFilter.some((ee) => ee.test(file))) {
|
||||
continue;
|
||||
}
|
||||
if (await this.plugin.$$isIgnoredByIgnoreFiles(file)) continue;
|
||||
files.push(file);
|
||||
@@ -259,16 +254,12 @@ export class ModuleFileAccessObsidian extends AbstractObsidianModule implements
|
||||
if (skipFolder.some((e) => folderName === e)) {
|
||||
continue;
|
||||
}
|
||||
if (excludeFilter && excludeFilter.some((e) => v.match(e))) {
|
||||
if (includeFilter) {
|
||||
if (!includeFilter.some((e) => v.match(e))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (includeFilter) {
|
||||
if (!includeFilter.some((e) => v.match(e))) continue;
|
||||
if (excludeFilter && excludeFilter.some((e) => e.test(v))) {
|
||||
continue;
|
||||
}
|
||||
if (await this.plugin.$$isIgnoredByIgnoreFiles(v)) {
|
||||
continue;
|
||||
}
|
||||
// OK, deep dive!
|
||||
files = files.concat(await this.getFilesIncludeHidden(v, includeFilter, excludeFilter, skipFolder));
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
type UXFileInfoStub,
|
||||
type UXInternalFileInfoStub,
|
||||
} from "../../../lib/src/common/types.ts";
|
||||
import { delay, fireAndForget } from "../../../lib/src/common/utils.ts";
|
||||
import { delay, fireAndForget, getFileRegExp } from "../../../lib/src/common/utils.ts";
|
||||
import { type FileEventItem, type FileEventType } from "../../../common/types.ts";
|
||||
import { serialized, skipIfDuplicated } from "../../../lib/src/concurrency/lock.ts";
|
||||
import {
|
||||
@@ -161,12 +161,10 @@ export class StorageEventManagerObsidian extends StorageEventManager {
|
||||
if (!this.plugin.settings.syncInternalFiles && !this.plugin.settings.usePluginSync) return;
|
||||
if (!this.plugin.settings.watchInternalFileChanges) return;
|
||||
if (!path.startsWith(this.plugin.app.vault.configDir)) return;
|
||||
const ignorePatterns = this.plugin.settings.syncInternalFilesIgnorePatterns
|
||||
.replace(/\n| /g, "")
|
||||
.split(",")
|
||||
.filter((e) => e)
|
||||
.map((e) => new RegExp(e, "i"));
|
||||
if (ignorePatterns.some((e) => path.match(e))) return;
|
||||
const ignorePatterns = getFileRegExp(this.plugin.settings, "syncInternalFilesIgnorePatterns");
|
||||
const targetPatterns = getFileRegExp(this.plugin.settings, "syncInternalFilesTargetPatterns");
|
||||
if (ignorePatterns.some((e) => e.test(path))) return;
|
||||
if (!targetPatterns.some((e) => e.test(path))) return;
|
||||
if (path.endsWith("/")) {
|
||||
// Folder
|
||||
return;
|
||||
|
||||
@@ -17,17 +17,8 @@ import { AuthorizationHeaderGenerator } from "../../lib/src/replication/httplib.
|
||||
|
||||
setNoticeClass(Notice);
|
||||
|
||||
async function fetchByAPI(request: RequestUrlParam): Promise<RequestUrlResponse> {
|
||||
const ret = await requestUrl(request);
|
||||
if (ret.status - (ret.status % 100) !== 200) {
|
||||
const er: Error & { status?: number } = new Error(`Request Error:${ret.status}`);
|
||||
if (ret.json) {
|
||||
er.message = ret.json.reason;
|
||||
er.name = `${ret.json.error ?? ""}:${ret.json.message ?? ""}`;
|
||||
}
|
||||
er.status = ret.status;
|
||||
throw er;
|
||||
}
|
||||
async function fetchByAPI(request: RequestUrlParam, errorAsResult = false): Promise<RequestUrlResponse> {
|
||||
const ret = await requestUrl({ ...request, throw: !errorAsResult });
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -45,13 +36,7 @@ export class ModuleObsidianAPI extends AbstractObsidianModule implements IObsidi
|
||||
return !this.last_successful_post;
|
||||
}
|
||||
|
||||
async fetchByAPI(
|
||||
url: string,
|
||||
localURL: string,
|
||||
method: string,
|
||||
authHeader: string,
|
||||
opts?: RequestInit
|
||||
): Promise<Response> {
|
||||
async _fetchByAPI(url: string, authHeader: string, opts?: RequestInit): Promise<Response> {
|
||||
const body = opts?.body as string;
|
||||
|
||||
const transformedHeaders = { ...(opts?.headers as Record<string, string>) };
|
||||
@@ -65,25 +50,36 @@ export class ModuleObsidianAPI extends AbstractObsidianModule implements IObsidi
|
||||
method: opts?.method,
|
||||
body: body,
|
||||
headers: transformedHeaders,
|
||||
contentType: "application/json",
|
||||
// contentType: opts.headers,
|
||||
contentType:
|
||||
transformedHeaders?.["content-type"] ?? transformedHeaders?.["Content-Type"] ?? "application/json",
|
||||
};
|
||||
const r = await fetchByAPI(requestParam, true);
|
||||
return new Response(r.arrayBuffer, {
|
||||
headers: r.headers,
|
||||
status: r.status,
|
||||
statusText: `${r.status}`,
|
||||
});
|
||||
}
|
||||
|
||||
async fetchByAPI(
|
||||
url: string,
|
||||
localURL: string,
|
||||
method: string,
|
||||
authHeader: string,
|
||||
opts?: RequestInit
|
||||
): Promise<Response> {
|
||||
const body = opts?.body as string;
|
||||
const size = body ? ` (${body.length})` : "";
|
||||
try {
|
||||
const r = await this._fetchByAPI(url, authHeader, opts);
|
||||
this.plugin.requestCount.value = this.plugin.requestCount.value + 1;
|
||||
const r = await fetchByAPI(requestParam);
|
||||
if (method == "POST" || method == "PUT") {
|
||||
this.last_successful_post = r.status - (r.status % 100) == 200;
|
||||
} else {
|
||||
this.last_successful_post = true;
|
||||
}
|
||||
this._log(`HTTP:${method}${size} to:${localURL} -> ${r.status}`, LOG_LEVEL_DEBUG);
|
||||
|
||||
return new Response(r.arrayBuffer, {
|
||||
headers: r.headers,
|
||||
status: r.status,
|
||||
statusText: `${r.status}`,
|
||||
});
|
||||
return r;
|
||||
} catch (ex) {
|
||||
this._log(`HTTP:${method}${size} to:${localURL} -> failed`, LOG_LEVEL_VERBOSE);
|
||||
// limit only in bulk_docs.
|
||||
@@ -106,7 +102,8 @@ export class ModuleObsidianAPI extends AbstractObsidianModule implements IObsidi
|
||||
performSetup: boolean,
|
||||
skipInfo: boolean,
|
||||
compression: boolean,
|
||||
customHeaders: Record<string, string>
|
||||
customHeaders: Record<string, string>,
|
||||
useRequestAPI: boolean
|
||||
): Promise<string | { db: PouchDB.Database<EntryDoc>; info: PouchDB.Core.DatabaseInfo }> {
|
||||
if (!isValidRemoteCouchDBURI(uri)) return "Remote URI is not valid";
|
||||
if (uri.toLowerCase() != uri) return "Remote URI and database name could not contain capital letters.";
|
||||
@@ -147,15 +144,11 @@ export class ModuleObsidianAPI extends AbstractObsidianModule implements IObsidi
|
||||
headers.append("authorization", authHeader);
|
||||
}
|
||||
|
||||
if (!disableRequestURI && typeof url == "string" && typeof (opts?.body ?? "") == "string") {
|
||||
// Deprecated configuration, only for backward compatibility.
|
||||
return await this.fetchByAPI(url, localURL, method, authHeader, { ...opts, headers });
|
||||
}
|
||||
// --> native Fetch API.
|
||||
|
||||
try {
|
||||
this.plugin.requestCount.value = this.plugin.requestCount.value + 1;
|
||||
const response: Response = await fetch(url, { ...opts, headers });
|
||||
const response: Response = await (useRequestAPI
|
||||
? this._fetchByAPI(url.toString(), authHeader, { ...opts, headers })
|
||||
: fetch(url, { ...opts, headers }));
|
||||
if (method == "POST" || method == "PUT") {
|
||||
this.last_successful_post = response.ok;
|
||||
} else {
|
||||
@@ -188,6 +181,10 @@ export class ModuleObsidianAPI extends AbstractObsidianModule implements IObsidi
|
||||
return response;
|
||||
} catch (ex) {
|
||||
if (ex instanceof TypeError) {
|
||||
if (useRequestAPI) {
|
||||
this._log("Failed to request by API.");
|
||||
throw ex;
|
||||
}
|
||||
this._log(
|
||||
"Failed to fetch by native fetch API. Trying to fetch by API to get more information."
|
||||
);
|
||||
|
||||
@@ -7,6 +7,7 @@ import { uint8ArrayToHexString } from "octagonal-wheels/binary/hex";
|
||||
import { parseYaml, requestUrl, stringifyYaml } from "obsidian";
|
||||
import type { FilePath } from "../../lib/src/common/types.ts";
|
||||
import { scheduleTask } from "octagonal-wheels/concurrency/task";
|
||||
import { getFileRegExp } from "../../lib/src/common/utils.ts";
|
||||
|
||||
declare global {
|
||||
interface LSEvents {
|
||||
@@ -200,13 +201,10 @@ export class ModuleReplicateTest extends AbstractObsidianModule implements IObsi
|
||||
}
|
||||
|
||||
async _dumpFileListIncludeHidden(outFile?: string) {
|
||||
const ignorePatterns = this.settings.syncInternalFilesIgnorePatterns
|
||||
.replace(/\n| /g, "")
|
||||
.split(",")
|
||||
.filter((e) => e)
|
||||
.map((e) => new RegExp(e, "i"));
|
||||
const ignorePatterns = getFileRegExp(this.plugin.settings, "syncInternalFilesIgnorePatterns");
|
||||
const targetPatterns = getFileRegExp(this.plugin.settings, "syncInternalFilesTargetPatterns");
|
||||
const out = [] as any[];
|
||||
const files = await this.core.storageAccess.getFilesIncludeHidden("", undefined, ignorePatterns);
|
||||
const files = await this.core.storageAccess.getFilesIncludeHidden("", targetPatterns, ignorePatterns);
|
||||
// console.dir(files);
|
||||
const webcrypto = await getWebCrypto();
|
||||
for (const file of files) {
|
||||
|
||||
@@ -63,6 +63,7 @@ export class ModuleLog extends AbstractObsidianModule implements IObsidianModule
|
||||
|
||||
statusBarLabels!: ReactiveValue<{ message: string; status: string }>;
|
||||
statusLog = reactiveSource("");
|
||||
activeFileStatus = reactiveSource("");
|
||||
notifies: { [key: string]: { notice: Notice; count: number } } = {};
|
||||
p2pLogCollector = new P2PLogCollector();
|
||||
|
||||
@@ -181,10 +182,11 @@ export class ModuleLog extends AbstractObsidianModule implements IObsidianModule
|
||||
? `WARNING! RESTARTING OBSIDIAN IS SCHEDULED!\n`
|
||||
: "";
|
||||
const { message } = statusLineLabel();
|
||||
const fileStatus = this.activeFileStatus.value;
|
||||
const status = scheduleMessage + this.statusLog.value;
|
||||
|
||||
const fileStatusIcon = `${fileStatus && this.settings.hideFileWarningNotice ? " ⛔ SKIP" : ""}`;
|
||||
return {
|
||||
message,
|
||||
message: `${message}${fileStatusIcon}`,
|
||||
status,
|
||||
};
|
||||
});
|
||||
@@ -229,7 +231,9 @@ export class ModuleLog extends AbstractObsidianModule implements IObsidianModule
|
||||
return "";
|
||||
}
|
||||
async setFileStatus() {
|
||||
this.messageArea!.innerText = await this.getActiveFileStatus();
|
||||
const fileStatus = await this.getActiveFileStatus();
|
||||
this.activeFileStatus.value = fileStatus;
|
||||
this.messageArea!.innerText = this.settings.hideFileWarningNotice ? "" : fileStatus;
|
||||
}
|
||||
onActiveLeafChange() {
|
||||
fireAndForget(async () => {
|
||||
|
||||
@@ -11,9 +11,45 @@ import {
|
||||
} from "../../lib/src/common/types";
|
||||
import { LOG_LEVEL_NOTICE, LOG_LEVEL_URGENT } from "octagonal-wheels/common/logger";
|
||||
import { encrypt, tryDecrypt } from "octagonal-wheels/encryption";
|
||||
import { setLang } from "../../lib/src/common/i18n";
|
||||
import { $msg, setLang } from "../../lib/src/common/i18n";
|
||||
import { isCloudantURI } from "../../lib/src/pouchdb/utils_couchdb";
|
||||
import { getLanguage } from "obsidian";
|
||||
import { SUPPORTED_I18N_LANGS, type I18N_LANGS } from "../../lib/src/common/rosetta.ts";
|
||||
export class ModuleObsidianSettings extends AbstractObsidianModule implements IObsidianModule {
|
||||
async $everyOnLayoutReady(): Promise<boolean> {
|
||||
let isChanged = false;
|
||||
if (this.settings.displayLanguage == "") {
|
||||
const obsidianLanguage = getLanguage();
|
||||
if (
|
||||
SUPPORTED_I18N_LANGS.indexOf(obsidianLanguage) !== -1 && // Check if the language is supported
|
||||
obsidianLanguage != this.settings.displayLanguage && // Check if the language is different from the current setting
|
||||
this.settings.displayLanguage != ""
|
||||
) {
|
||||
// Check if the current setting is not empty (Means migrated or installed).
|
||||
this.settings.displayLanguage = obsidianLanguage as I18N_LANGS;
|
||||
isChanged = true;
|
||||
setLang(this.settings.displayLanguage);
|
||||
} else if (this.settings.displayLanguage == "") {
|
||||
this.settings.displayLanguage = "def";
|
||||
setLang(this.settings.displayLanguage);
|
||||
await this.core.$$saveSettingData();
|
||||
}
|
||||
}
|
||||
if (isChanged) {
|
||||
const revert = $msg("dialog.yourLanguageAvailable.btnRevertToDefault");
|
||||
if (
|
||||
(await this.core.confirm.askSelectStringDialogue($msg(`dialog.yourLanguageAvailable`), ["OK", revert], {
|
||||
defaultAction: "OK",
|
||||
title: $msg(`dialog.yourLanguageAvailable.Title`),
|
||||
})) == revert
|
||||
) {
|
||||
this.settings.displayLanguage = "def";
|
||||
setLang(this.settings.displayLanguage);
|
||||
}
|
||||
await this.core.$$saveSettingData();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
getPassphrase(settings: ObsidianLiveSyncSettings) {
|
||||
const methods: Record<ConfigPassphraseStore, () => Promise<string | false>> = {
|
||||
"": () => Promise.resolve("*"),
|
||||
@@ -199,6 +235,7 @@ export class ModuleObsidianSettings extends AbstractObsidianModule implements IO
|
||||
}
|
||||
}
|
||||
this.settings = settings;
|
||||
|
||||
setLang(this.settings.displayLanguage);
|
||||
|
||||
if ("workingEncrypt" in this.settings) delete this.settings.workingEncrypt;
|
||||
|
||||
@@ -67,14 +67,13 @@ export class ModuleSetupObsidian extends AbstractObsidianModule implements IObsi
|
||||
const fullIndexes = Object.entries(KeyIndexOfSettings) as [keyof ObsidianLiveSyncSettings, number][];
|
||||
for (const [settingKey, index] of fullIndexes) {
|
||||
const settingValue = this.settings[settingKey];
|
||||
if (index < 0) {
|
||||
// This setting should be ignored.
|
||||
continue;
|
||||
}
|
||||
settingArr[index] = settingValue;
|
||||
}
|
||||
const w = encodeAnyArray(settingArr);
|
||||
// console.warn(w.length)
|
||||
// console.warn(w);
|
||||
// const j = decodeAnyArray(w);
|
||||
// console.warn(j);
|
||||
// console.warn(`is equal: ${isObjectDifferent(settingArr, j)}`);
|
||||
const qr = qrcode(0, "L");
|
||||
const uri = `${configURIBaseQR}${encodeURIComponent(w)}`;
|
||||
qr.addData(uri);
|
||||
@@ -90,6 +89,10 @@ export class ModuleSetupObsidian extends AbstractObsidianModule implements IObsi
|
||||
const fullIndexes = Object.entries(KeyIndexOfSettings) as [keyof ObsidianLiveSyncSettings, number][];
|
||||
const newSettings = { ...DEFAULT_SETTINGS } as ObsidianLiveSyncSettings;
|
||||
for (const [settingKey, index] of fullIndexes) {
|
||||
if (index < 0) {
|
||||
// This setting should be ignored.
|
||||
continue;
|
||||
}
|
||||
if (index >= settingArr.length) {
|
||||
// Possibly a new setting added.
|
||||
continue;
|
||||
|
||||
@@ -1,31 +1,28 @@
|
||||
<script lang="ts">
|
||||
export let patterns = [] as string[];
|
||||
export let originals = [] as string[];
|
||||
import type { CustomRegExpSource } from "../../../lib/src/common/types";
|
||||
import { isInvertedRegExp, isValidRegExp } from "../../../lib/src/common/utils";
|
||||
|
||||
export let apply: (args: string[]) => Promise<void> = (_: string[]) => Promise.resolve();
|
||||
export let patterns = [] as CustomRegExpSource[];
|
||||
export let originals = [] as CustomRegExpSource[];
|
||||
|
||||
export let apply: (args: CustomRegExpSource[]) => Promise<void> = (_: CustomRegExpSource[]) => Promise.resolve();
|
||||
function revert() {
|
||||
patterns = [...originals];
|
||||
}
|
||||
const CHECK_OK = "✔";
|
||||
const CHECK_NG = "⚠";
|
||||
const MARK_MODIFIED = "✏ ";
|
||||
function checkRegExp(pattern: string) {
|
||||
if (pattern.trim() == "") return "";
|
||||
try {
|
||||
new RegExp(pattern);
|
||||
return CHECK_OK;
|
||||
} catch (ex) {
|
||||
return CHECK_NG;
|
||||
}
|
||||
function checkRegExp(pattern: CustomRegExpSource) {
|
||||
return isValidRegExp(pattern) ? CHECK_OK : CHECK_NG;
|
||||
}
|
||||
$: statusName = patterns.map((e) => checkRegExp(e));
|
||||
$: modified = patterns.map((e, i) => (e != (originals?.[i] ?? "") ? MARK_MODIFIED : ""));
|
||||
|
||||
$: isInvertedExp = patterns.map((e) => isInvertedRegExp(e));
|
||||
function remove(idx: number) {
|
||||
patterns[idx] = "";
|
||||
patterns[idx] = "" as CustomRegExpSource;
|
||||
}
|
||||
function add() {
|
||||
patterns = [...patterns, ""];
|
||||
patterns = [...patterns, "" as CustomRegExpSource];
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -33,7 +30,9 @@
|
||||
{#each patterns as pattern, idx}
|
||||
<!-- svelte-ignore a11y-label-has-associated-control -->
|
||||
<li>
|
||||
<label>{modified[idx]}{statusName[idx]}</label><input type="text" bind:value={pattern} class={modified[idx]} />
|
||||
<label>{modified[idx]}{statusName[idx]}</label>
|
||||
<span class="chip">{isInvertedExp[idx] ? "INVERTED" : ""}</span>
|
||||
<input type="text" bind:value={pattern} class={modified[idx]} />
|
||||
<button class="iconbutton" on:click={() => remove(idx)}>🗑</button>
|
||||
</li>
|
||||
{/each}
|
||||
@@ -43,8 +42,16 @@
|
||||
</label>
|
||||
</li>
|
||||
<li class="buttons">
|
||||
<button on:click={() => apply(patterns)} disabled={statusName.some((e) => e === CHECK_NG) || modified.every((e) => e === "")}>Apply </button>
|
||||
<button on:click={() => revert()} disabled={statusName.some((e) => e === CHECK_NG) || modified.every((e) => e === "")}>Revert </button>
|
||||
<button
|
||||
on:click={() => apply(patterns)}
|
||||
disabled={statusName.some((e) => e === CHECK_NG) || modified.every((e) => e === "")}
|
||||
>Apply
|
||||
</button>
|
||||
<button
|
||||
on:click={() => revert()}
|
||||
disabled={statusName.some((e) => e === CHECK_NG) || modified.every((e) => e === "")}
|
||||
>Revert
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -85,4 +92,14 @@
|
||||
button.iconbutton {
|
||||
max-width: 4em;
|
||||
}
|
||||
.chip {
|
||||
background-color: var(--tag-background);
|
||||
color: var(--tag-color);
|
||||
padding: var(--size-2-1) var(--size-4-1);
|
||||
border-radius: 0.5em;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
.chip:empty {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -26,15 +26,19 @@ import {
|
||||
type MetaEntry,
|
||||
type FilePath,
|
||||
REMOTE_P2P,
|
||||
type CustomRegExpSource,
|
||||
} from "../../../lib/src/common/types.ts";
|
||||
import {
|
||||
constructCustomRegExpList,
|
||||
createBlob,
|
||||
delay,
|
||||
getFileRegExp,
|
||||
isDocContentSame,
|
||||
isObjectDifferent,
|
||||
parseHeaderValues,
|
||||
readAsBlob,
|
||||
sizeToHumanReadable,
|
||||
splitCustomRegExpList,
|
||||
} from "../../../lib/src/common/utils.ts";
|
||||
import { arrayBufferToBase64Single, versionNumberString2Number } from "../../../lib/src/string_and_binary/convert.ts";
|
||||
import { Logger } from "../../../lib/src/common/logger.ts";
|
||||
@@ -1132,7 +1136,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
||||
(paneEl) => {
|
||||
void addPanel(paneEl, $msg("obsidianLiveSyncSettingTab.titleAppearance")).then((paneEl) => {
|
||||
const languages = Object.fromEntries([
|
||||
["", $msg("obsidianLiveSyncSettingTab.defaultLanguage")],
|
||||
// ["", $msg("obsidianLiveSyncSettingTab.defaultLanguage")],
|
||||
...SUPPORTED_I18N_LANGS.map((e) => [e, $t(`lang-${e}`)]),
|
||||
]) as Record<I18N_LANGS, string>;
|
||||
new Setting(paneEl).autoWireDropDown("displayLanguage", {
|
||||
@@ -1144,6 +1148,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
||||
onUpdate: visibleOnly(() => this.isConfiguredAs("showStatusOnEditor", true)),
|
||||
});
|
||||
new Setting(paneEl).autoWireToggle("showStatusOnStatusbar");
|
||||
new Setting(paneEl).autoWireToggle("hideFileWarningNotice");
|
||||
});
|
||||
void addPanel(paneEl, $msg("obsidianLiveSyncSettingTab.titleLogging")).then((paneEl) => {
|
||||
paneEl.addClass("wizardHidden");
|
||||
@@ -2218,13 +2223,10 @@ The pane also can be launched by \`P2P Replicator\` command from the Command Pal
|
||||
mount(MultipleRegExpControl, {
|
||||
target: syncFilesSetting.controlEl,
|
||||
props: {
|
||||
patterns: this.editingSettings.syncOnlyRegEx.split("|[]|"),
|
||||
originals: [...this.editingSettings.syncOnlyRegEx.split("|[]|")],
|
||||
apply: async (newPatterns: string[]) => {
|
||||
this.editingSettings.syncOnlyRegEx = newPatterns
|
||||
.map((e: string) => e.trim())
|
||||
.filter((e) => e != "")
|
||||
.join("|[]|");
|
||||
patterns: splitCustomRegExpList(this.editingSettings.syncOnlyRegEx, "|[]|"),
|
||||
originals: splitCustomRegExpList(this.editingSettings.syncOnlyRegEx, "|[]|"),
|
||||
apply: async (newPatterns: CustomRegExpSource[]) => {
|
||||
this.editingSettings.syncOnlyRegEx = constructCustomRegExpList(newPatterns, "|[]|");
|
||||
await this.saveAllDirtySettings();
|
||||
this.display();
|
||||
},
|
||||
@@ -2241,13 +2243,10 @@ The pane also can be launched by \`P2P Replicator\` command from the Command Pal
|
||||
mount(MultipleRegExpControl, {
|
||||
target: nonSyncFilesSetting.controlEl,
|
||||
props: {
|
||||
patterns: this.editingSettings.syncIgnoreRegEx.split("|[]|"),
|
||||
originals: [...this.editingSettings.syncIgnoreRegEx.split("|[]|")],
|
||||
apply: async (newPatterns: string[]) => {
|
||||
this.editingSettings.syncIgnoreRegEx = newPatterns
|
||||
.map((e) => e.trim())
|
||||
.filter((e) => e != "")
|
||||
.join("|[]|");
|
||||
patterns: splitCustomRegExpList(this.editingSettings.syncIgnoreRegEx, "|[]|"),
|
||||
originals: splitCustomRegExpList(this.editingSettings.syncIgnoreRegEx, "|[]|"),
|
||||
apply: async (newPatterns: CustomRegExpSource[]) => {
|
||||
this.editingSettings.syncIgnoreRegEx = constructCustomRegExpList(newPatterns, "|[]|");
|
||||
await this.saveAllDirtySettings();
|
||||
this.display();
|
||||
},
|
||||
@@ -2261,14 +2260,32 @@ The pane also can be launched by \`P2P Replicator\` command from the Command Pal
|
||||
});
|
||||
});
|
||||
void addPanel(paneEl, "Hidden Files", undefined, undefined, LEVEL_ADVANCED).then((paneEl) => {
|
||||
const targetPatternSetting = new Setting(paneEl)
|
||||
.setName("Target patterns")
|
||||
.setClass("wizardHidden")
|
||||
.setDesc("Patterns to match files for syncing");
|
||||
const patTarget = splitCustomRegExpList(this.editingSettings.syncInternalFilesTargetPatterns, ",");
|
||||
mount(MultipleRegExpControl, {
|
||||
target: targetPatternSetting.controlEl,
|
||||
props: {
|
||||
patterns: patTarget,
|
||||
originals: [...patTarget],
|
||||
apply: async (newPatterns: CustomRegExpSource[]) => {
|
||||
this.editingSettings.syncInternalFilesTargetPatterns = constructCustomRegExpList(
|
||||
newPatterns,
|
||||
","
|
||||
);
|
||||
await this.saveAllDirtySettings();
|
||||
this.display();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const defaultSkipPattern = "\\/node_modules\\/, \\/\\.git\\/, ^\\.git\\/, \\/obsidian-livesync\\/";
|
||||
const defaultSkipPatternXPlat =
|
||||
defaultSkipPattern + ",\\/workspace$ ,\\/workspace.json$,\\/workspace-mobile.json$";
|
||||
|
||||
const pat = this.editingSettings.syncInternalFilesIgnorePatterns
|
||||
.split(",")
|
||||
.map((x) => x.trim())
|
||||
.filter((x) => x != "");
|
||||
const pat = splitCustomRegExpList(this.editingSettings.syncInternalFilesIgnorePatterns, ",");
|
||||
const patSetting = new Setting(paneEl).setName("Ignore patterns").setClass("wizardHidden").setDesc("");
|
||||
|
||||
mount(MultipleRegExpControl, {
|
||||
@@ -2276,11 +2293,11 @@ The pane also can be launched by \`P2P Replicator\` command from the Command Pal
|
||||
props: {
|
||||
patterns: pat,
|
||||
originals: [...pat],
|
||||
apply: async (newPatterns: string[]) => {
|
||||
this.editingSettings.syncInternalFilesIgnorePatterns = newPatterns
|
||||
.map((e) => e.trim())
|
||||
.filter((e) => e != "")
|
||||
.join(", ");
|
||||
apply: async (newPatterns: CustomRegExpSource[]) => {
|
||||
this.editingSettings.syncInternalFilesIgnorePatterns = constructCustomRegExpList(
|
||||
newPatterns,
|
||||
","
|
||||
);
|
||||
await this.saveAllDirtySettings();
|
||||
this.display();
|
||||
},
|
||||
@@ -2288,16 +2305,13 @@ The pane also can be launched by \`P2P Replicator\` command from the Command Pal
|
||||
});
|
||||
|
||||
const addDefaultPatterns = async (patterns: string) => {
|
||||
const oldList = this.editingSettings.syncInternalFilesIgnorePatterns
|
||||
.split(",")
|
||||
.map((x) => x.trim())
|
||||
.filter((x) => x != "");
|
||||
const newList = patterns
|
||||
.split(",")
|
||||
.map((x) => x.trim())
|
||||
.filter((x) => x != "");
|
||||
const allSet = new Set([...oldList, ...newList]);
|
||||
this.editingSettings.syncInternalFilesIgnorePatterns = [...allSet].join(", ");
|
||||
const oldList = splitCustomRegExpList(this.editingSettings.syncInternalFilesIgnorePatterns, ",");
|
||||
const newList = splitCustomRegExpList(
|
||||
patterns as unknown as typeof this.editingSettings.syncInternalFilesIgnorePatterns,
|
||||
","
|
||||
);
|
||||
const allSet = new Set<CustomRegExpSource>([...oldList, ...newList]);
|
||||
this.editingSettings.syncInternalFilesIgnorePatterns = constructCustomRegExpList([...allSet], ",");
|
||||
await this.saveAllDirtySettings();
|
||||
this.display();
|
||||
};
|
||||
@@ -2691,17 +2705,20 @@ ${stringifyYaml(pluginConfig)}`;
|
||||
.setCta()
|
||||
.onClick(async () => {
|
||||
Logger("Start verifying all files", LOG_LEVEL_NOTICE, "verify");
|
||||
const ignorePatterns = this.plugin.settings.syncInternalFilesIgnorePatterns
|
||||
.replace(/\n| /g, "")
|
||||
.split(",")
|
||||
.filter((e) => e)
|
||||
.map((e) => new RegExp(e, "i"));
|
||||
const ignorePatterns = getFileRegExp(
|
||||
this.plugin.settings,
|
||||
"syncInternalFilesIgnorePatterns"
|
||||
);
|
||||
const targetPatterns = getFileRegExp(
|
||||
this.plugin.settings,
|
||||
"syncInternalFilesTargetPatterns"
|
||||
);
|
||||
this.plugin.localDatabase.hashCaches.clear();
|
||||
Logger("Start verifying all files", LOG_LEVEL_NOTICE, "verify");
|
||||
const files = this.plugin.settings.syncInternalFiles
|
||||
? await this.plugin.storageAccess.getFilesIncludeHidden(
|
||||
"/",
|
||||
undefined,
|
||||
targetPatterns,
|
||||
ignorePatterns
|
||||
)
|
||||
: await this.plugin.storageAccess.getFileNames();
|
||||
@@ -2721,7 +2738,7 @@ ${stringifyYaml(pluginConfig)}`;
|
||||
i++;
|
||||
if (i % 25 == 0)
|
||||
Logger(
|
||||
`Checking ${i}/${files.length} files \n`,
|
||||
`Checking ${i}/${allPaths.length} files \n`,
|
||||
LOG_LEVEL_NOTICE,
|
||||
"verify-processed"
|
||||
);
|
||||
@@ -3087,7 +3104,9 @@ ${stringifyYaml(pluginConfig)}`;
|
||||
onUpdate: visibleOnly(() => this.isConfiguredAs("disableWorkerForGeneratingChunks", false)),
|
||||
});
|
||||
});
|
||||
|
||||
void addPanel(paneEl, "Edge case addressing (Networking)").then((paneEl) => {
|
||||
new Setting(paneEl).autoWireToggle("useRequestAPI");
|
||||
});
|
||||
void addPanel(paneEl, "Compatibility (Trouble addressed)").then((paneEl) => {
|
||||
new Setting(paneEl).autoWireToggle("disableCheckingConfigMismatch");
|
||||
});
|
||||
|
||||
@@ -377,6 +377,14 @@ export const SettingInformation: Partial<Record<keyof AllSettings, Configuration
|
||||
name: "Minimum interval for syncing",
|
||||
desc: "The minimum interval for automatic synchronisation on event.",
|
||||
},
|
||||
useRequestAPI: {
|
||||
name: "Use Request API to avoid `inevitable` CORS problem",
|
||||
desc: "If enabled, the request API will be used to avoid `inevitable` CORS problems. This is a workaround and may not work in all cases. PLEASE READ THE DOCUMENTATION BEFORE USING THIS OPTION. This is a less-secure option.",
|
||||
},
|
||||
hideFileWarningNotice: {
|
||||
name: "Show status icon instead of file warnings banner",
|
||||
desc: "If enabled, the ⛔ icon will be shown inside the status instead of the file warnings banner. No details will be shown.",
|
||||
},
|
||||
};
|
||||
function translateInfo(infoSrc: ConfigurationItem | undefined | false) {
|
||||
if (!infoSrc) return false;
|
||||
|
||||
@@ -7,6 +7,7 @@ import type {
|
||||
UXFolderInfo,
|
||||
UXStat,
|
||||
} from "../../lib/src/common/types";
|
||||
import type { CustomRegExp } from "../../lib/src/common/utils";
|
||||
|
||||
export interface StorageAccess {
|
||||
deleteVaultItem(file: FilePathWithPrefix | UXFileInfoStub | UXFolderInfo): Promise<void>;
|
||||
@@ -48,8 +49,8 @@ export interface StorageAccess {
|
||||
|
||||
getFilesIncludeHidden(
|
||||
basePath: string,
|
||||
includeFilter?: RegExp[],
|
||||
excludeFilter?: RegExp[],
|
||||
includeFilter?: CustomRegExp[],
|
||||
excludeFilter?: CustomRegExp[],
|
||||
skipFolder?: string[]
|
||||
): Promise<FilePath[]>;
|
||||
}
|
||||
|
||||
194
updates.md
194
updates.md
@@ -1,112 +1,138 @@
|
||||
## 0.24.11
|
||||
## 0.24.26
|
||||
|
||||
Peer-to-peer synchronisation has been implemented!
|
||||
This update introduces an option to circumvent Cross-Origin Resource Sharing
|
||||
(CORS) constraints for CouchDB requests, by leveraging Obsidian's native request
|
||||
API. The implementation of such a feature had previously been deferred due to
|
||||
significant security considerations.
|
||||
|
||||
Until now, I have not provided a synchronisation server. More people may not even know that I have shut down the test server. I confess that this is a bit repetitive, but I confess it is a cautionary tale. This is out of a sense of self-discipline that someone has occurred who could see your data. Even if the 'someone' is me. I should not be unaware of its superiority, even though well-meaning and am a servant of all. (Half joking, but also serious).
|
||||
However, now I can provide you with a signalling server. Because, to the best of my knowledge, it is only the network that is connected to your device.
|
||||
Also, this signalling server is just a Nostr relay, not my implementation. You can run your implementation, which you consider trustworthy, on a trustworthy server. You do not even have to trust me. Mate, it is great, isn't it? For your information, strfry is running on my signalling server.
|
||||
CORS is a vital security mechanism, enabling servers like CouchDB -- which
|
||||
functions as a sophisticated REST API -- to control access from different
|
||||
origins, thereby ensuring secure communication across trust boundaries. I had
|
||||
long hesitated to offer a CORS circumvention method, as it deviates from
|
||||
security best practices; My preference was for users to configure CORS correctly
|
||||
on the server-side.
|
||||
|
||||
Nevertheless, that being said, to be more honest, I still have not decided what to do with this signalling server if too much traffic comes in.
|
||||
However, this policy has shifted due to specific reports of intractable
|
||||
CORS-related configuration issues, particularly within enterprise proxy
|
||||
environments where proxy servers can unpredictably alter or block
|
||||
communications. Given that a primary objective of the "Self-hosted LiveSync"
|
||||
plugin is to facilitate secure Obsidian usage within stringent corporate
|
||||
settings, addressing these 'unavoidable' user-reported problems became
|
||||
essential. Mostly raison d'être of this plugin.
|
||||
|
||||
Note: Already you have noticed this, but let me mention it again, this is a significantly large update. If you have noticed anything, please let me know. I will try to fix it as soon as possible (Some address is on my [profile](https://github.com/vrtmrz)).
|
||||
Consequently, the option "Use Request API to avoid `inevitable` CORS problem"
|
||||
has been implemented. Users are strongly advised to enable this _only_ when
|
||||
operating within a trusted environment. We can enable this option in the `Patch` pane.
|
||||
|
||||
However, just to whisper, this is tremendously fast.
|
||||
|
||||
### New Features
|
||||
|
||||
- Automatic display-language changing according to the Obsidian language
|
||||
setting.
|
||||
- We will be asked on the migration or first startup.
|
||||
- **Note: Please revert to the default language if you report any issues.**
|
||||
- Not all messages are translated yet. We welcome your contribution!
|
||||
- Now we can limit files to be synchronised even in the hidden files.
|
||||
- "Use Request API to avoid `inevitable` CORS problem" has been implemented.
|
||||
- Less secure, please use it only if you are sure that you are in the trusted
|
||||
environment and be able to ignore the CORS. No `Web viewer` or similar tools
|
||||
are recommended. (To avoid the origin forged attack). If you are able to
|
||||
configure the server setting, always that is recommended.
|
||||
- `Show status icon instead of file warnings banner` has been implemented.
|
||||
- If enabled, the ⛔ icon will be shown inside the status instead of the file
|
||||
warnings banner. No details will be shown.
|
||||
|
||||
### Improved
|
||||
|
||||
- All regular expressions can be inverted by prefixing `!!` now.
|
||||
|
||||
### Fixed
|
||||
|
||||
- No longer unexpected files will be gathered during hidden file sync.
|
||||
- No longer broken `\n` and new-line characters during the bucket
|
||||
synchronisation.
|
||||
- We can purge the remote bucket again if we using MinIO instead of AWS S3 or
|
||||
Cloudflare R2.
|
||||
- Purging the remote bucket is now more reliable.
|
||||
- 100 files are purged at a time.
|
||||
- Some wrong messages have been fixed.
|
||||
|
||||
### Behaviour changed
|
||||
|
||||
- Entering into the deeper directories to gather the hidden files is now limited
|
||||
by `/` or `\/` prefixed ignore filters. (It means that directories are scanned
|
||||
deeper than before).
|
||||
- However, inside the these directories, the files are still limited by the
|
||||
ignore filters.
|
||||
|
||||
### Etcetera
|
||||
|
||||
- Some code has been tidied up.
|
||||
- Trying less warning-suppressing and be more safer-coding.
|
||||
- Dependent libraries have been updated to the latest version.
|
||||
- Some build processes have been separated to `pre` and `post` processes.
|
||||
|
||||
## 0.24.25
|
||||
|
||||
### Improved
|
||||
|
||||
- Peer-to-peer synchronisation has been got more robust.
|
||||
|
||||
### Fixed
|
||||
|
||||
- No longer broken falsy values in settings during set-up by the QR code
|
||||
generation.
|
||||
|
||||
### Refactored
|
||||
|
||||
- Some `window` references now have pointed to `globalThis`.
|
||||
- Some sloppy-import has been fixed.
|
||||
- A server side implementation `Synchromesh` has been suffixed with `deno`
|
||||
instead of `server` now.
|
||||
|
||||
## 0.24.24
|
||||
|
||||
### Fixed
|
||||
|
||||
- No longer broken JSON files including `\n`, during the bucket synchronisation. (#623)
|
||||
- Custom headers and JWT tokens are now correctly sent to the server during configuration checking. (#624)
|
||||
- No longer broken JSON files including `\n`, during the bucket synchronisation.
|
||||
(#623)
|
||||
- Custom headers and JWT tokens are now correctly sent to the server during
|
||||
configuration checking. (#624)
|
||||
|
||||
### Improved
|
||||
|
||||
- Bucket synchronisation has been enhanced for better performance and reliability.
|
||||
- Now less duplicated chunks are sent to the server.
|
||||
Note: If you have encountered about too less chunks, please let me know. However, you can send it to the server by `Overwrite remote`.
|
||||
- Fetching conflicted files from the server is now more reliable.
|
||||
- Dependent libraries have been updated to the latest version.
|
||||
- Also, let me know if you have encountered any issues with this update. Especially you are using a device that has been in use for a little longer.
|
||||
- Bucket synchronisation has been enhanced for better performance and
|
||||
reliability.
|
||||
- Now less duplicated chunks are sent to the server. Note: If you have
|
||||
encountered about too less chunks, please let me know. However, you can send
|
||||
it to the server by `Overwrite remote`.
|
||||
- Fetching conflicted files from the server is now more reliable.
|
||||
- Dependent libraries have been updated to the latest version.
|
||||
- Also, let me know if you have encountered any issues with this update.
|
||||
Especially you are using a device that has been in use for a little
|
||||
longer.
|
||||
|
||||
## 0.24.23
|
||||
|
||||
### New Feature
|
||||
|
||||
- Now, we can send custom headers to the server.
|
||||
- They can be sent to either CouchDB or Object Storage.
|
||||
- They can be sent to either CouchDB or Object Storage.
|
||||
- Authentication with JWT in CouchDB is now supported.
|
||||
- I will describe steps later, but please refer to the [CouchDB document](https://docs.couchdb.org/en/stable/config/auth.html#authentication-configuration).
|
||||
- A JWT keypair for testing can be generated in the setting dialogue.
|
||||
- I will describe steps later, but please refer to the
|
||||
[CouchDB document](https://docs.couchdb.org/en/stable/config/auth.html#authentication-configuration).
|
||||
- A JWT keypair for testing can be generated in the setting dialogue.
|
||||
|
||||
### Improved
|
||||
|
||||
- The QR Code for set-up can be shown also from the setting dialogue now.
|
||||
- Conflict checking for preventing unexpected overwriting on the boot-up process has been quite faster.
|
||||
- Conflict checking for preventing unexpected overwriting on the boot-up process
|
||||
has been quite faster.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Some bugs on Dev and Testing modules have been fixed.
|
||||
|
||||
## 0.24.22 ~~0.24.21~~
|
||||
|
||||
(Really sorry for the confusion. I have got a miss at releasing...).
|
||||
|
||||
### Fixed
|
||||
|
||||
- No longer conflicted files are handled in the boot-up process. No more unexpected overwriting.
|
||||
- It ignores `Always overwrite with a newer file`, and always be prevented for the safety. Please pick it manually or open the file.
|
||||
- Some log messages on conflict resolution has been corrected.
|
||||
- Automatic merge notifications, displayed on the grounds of `same`, have been degraded to logs.
|
||||
|
||||
### Improved
|
||||
|
||||
- Now we can fetch the remote database with keeping local files completely intact.
|
||||
- In new option, all files are stored into the local database before the fetching, and will be merged automatically or detected as conflicts.
|
||||
- The dialogue presenting options when performing `Fetch` are now more informative.
|
||||
|
||||
### Refactored
|
||||
|
||||
- Some class methods have been fixed its arguments to be more consistent.
|
||||
- Types have been defined for some conditional results.
|
||||
|
||||
## 0.24.20
|
||||
|
||||
### Improved
|
||||
|
||||
- Now we can see the detail of `TypeError` using Obsidian API during remote database access.
|
||||
|
||||
## 0.24.19
|
||||
|
||||
### New Feature
|
||||
|
||||
- Now we can generate a QR Code for transferring the configuration to another device.
|
||||
- This QR Code can be scanned by the camera app or something QR Code Reader of another device, and via Obsidian URL, the configuration will be transferred.
|
||||
- Note: This QR Code is not encrypted. So, please be careful when transferring the configuration.
|
||||
|
||||
## 0.24.18
|
||||
|
||||
### Fixed
|
||||
|
||||
- Now no chunk creation errors will be raised after switching `Compute revisions for chunks`.
|
||||
- Some invisible file can be handled correctly (e.g., `writing-goals-history.csv`).
|
||||
- Fetching configuration from the server is now saves the configuration immediately (if we are not in the wizard).
|
||||
|
||||
### Improved
|
||||
|
||||
- Mismatched configuration dialogue is now more informative, and rewritten to more user-friendly.
|
||||
- Applying configuration mismatch is now without rebuilding (at our own risks).
|
||||
- Now, rebuilding is decided more fine grained.
|
||||
|
||||
### Improved internally
|
||||
|
||||
- Translations can be nested. i.e., task:`Some procedure`, check: `%{task} checking`, checkfailed: `%{check} failed` produces `Some procedure checking failed`.
|
||||
- Max to 10 levels of nesting
|
||||
|
||||
## 0.24.17
|
||||
|
||||
Confession. I got the default values wrong. So scary and sorry.
|
||||
|
||||
### Behaviour and default changed
|
||||
|
||||
- **NOW INDEED AND ACTUALLY** `Compute revisions for chunks` are backed into enabled again. it is necessary for garbage collection of chunks.
|
||||
- As far as existing users are concerned, this will not automatically change, but the Doctor will inform us.
|
||||
|
||||
Older notes are in [updates_old.md](https://github.com/vrtmrz/obsidian-livesync/blob/main/updates_old.md).
|
||||
Older notes are in
|
||||
[updates_old.md](https://github.com/vrtmrz/obsidian-livesync/blob/main/updates_old.md).
|
||||
|
||||
@@ -14,6 +14,78 @@ Thank you, and I hope your troubles will be resolved!
|
||||
|
||||
---
|
||||
|
||||
## 0.24.22 ~~0.24.21~~
|
||||
|
||||
(Really sorry for the confusion. I have got a miss at releasing...).
|
||||
|
||||
### Fixed
|
||||
|
||||
- No longer conflicted files are handled in the boot-up process. No more
|
||||
unexpected overwriting.
|
||||
- It ignores `Always overwrite with a newer file`, and always be prevented for
|
||||
the safety. Please pick it manually or open the file.
|
||||
- Some log messages on conflict resolution has been corrected.
|
||||
- Automatic merge notifications, displayed on the grounds of `same`, have been
|
||||
degraded to logs.
|
||||
|
||||
### Improved
|
||||
|
||||
- Now we can fetch the remote database with keeping local files completely
|
||||
intact.
|
||||
- In new option, all files are stored into the local database before the
|
||||
fetching, and will be merged automatically or detected as conflicts.
|
||||
- The dialogue presenting options when performing `Fetch` are now more
|
||||
informative.
|
||||
|
||||
### Refactored
|
||||
|
||||
- Some class methods have been fixed its arguments to be more consistent.
|
||||
- Types have been defined for some conditional results.
|
||||
|
||||
## 0.24.20
|
||||
|
||||
### Improved
|
||||
|
||||
- Now we can see the detail of `TypeError` using Obsidian API during remote
|
||||
database access.
|
||||
|
||||
### Behaviour and default changed
|
||||
|
||||
- **NOW INDEED AND ACTUALLY** `Compute revisions for chunks` are backed into
|
||||
enabled again. it is necessary for garbage collection of chunks.
|
||||
- As far as existing users are concerned, this will not automatically change,
|
||||
but the Doctor will inform us.
|
||||
|
||||
## 0.24.19
|
||||
|
||||
### New Feature
|
||||
|
||||
- Now we can generate a QR Code for transferring the configuration to another device.
|
||||
- This QR Code can be scanned by the camera app or something QR Code Reader of another device, and via Obsidian URL, the configuration will be transferred.
|
||||
- Note: This QR Code is not encrypted. So, please be careful when transferring the configuration.
|
||||
|
||||
## 0.24.18
|
||||
|
||||
### Fixed
|
||||
|
||||
- Now no chunk creation errors will be raised after switching `Compute revisions for chunks`.
|
||||
- Some invisible file can be handled correctly (e.g., `writing-goals-history.csv`).
|
||||
- Fetching configuration from the server is now saves the configuration immediately (if we are not in the wizard).
|
||||
|
||||
### Improved
|
||||
|
||||
- Mismatched configuration dialogue is now more informative, and rewritten to more user-friendly.
|
||||
- Applying configuration mismatch is now without rebuilding (at our own risks).
|
||||
- Now, rebuilding is decided more fine grained.
|
||||
|
||||
### Improved internally
|
||||
|
||||
- Translations can be nested. i.e., task:`Some procedure`, check: `%{task} checking`, checkfailed: `%{check} failed` produces `Some procedure checking failed`.
|
||||
- Max to 10 levels of nesting
|
||||
|
||||
## 0.24.17
|
||||
|
||||
Confession. I got the default values wrong. So scary and sorry.
|
||||
|
||||
## 0.24.16
|
||||
|
||||
@@ -116,6 +188,29 @@ And, this is just a single web page, without any server-side code. It is a stati
|
||||
|
||||
## 0.24.11
|
||||
|
||||
Peer-to-peer synchronisation has been implemented!
|
||||
|
||||
Until now, I have not provided a synchronisation server. More people may not
|
||||
even know that I have shut down the test server. I confess that this is a bit
|
||||
repetitive, but I confess it is a cautionary tale. This is out of a sense of
|
||||
self-discipline that someone has occurred who could see your data. Even if the
|
||||
'someone' is me. I should not be unaware of its superiority, even though
|
||||
well-meaning and am a servant of all. (Half joking, but also serious). However,
|
||||
now I can provide you with a signalling server. Because, to the best of my
|
||||
knowledge, it is only the network that is connected to your device. Also, this
|
||||
signalling server is just a Nostr relay, not my implementation. You can run your
|
||||
implementation, which you consider trustworthy, on a trustworthy server. You do
|
||||
not even have to trust me. Mate, it is great, isn't it? For your information,
|
||||
strfry is running on my signalling server.
|
||||
|
||||
Nevertheless, that being said, to be more honest, I still have not decided what
|
||||
to do with this signalling server if too much traffic comes in.
|
||||
|
||||
Note: Already you have noticed this, but let me mention it again, this is a
|
||||
significantly large update. If you have noticed anything, please let me know. I
|
||||
will try to fix it as soon as possible (Some address is on my
|
||||
[profile](https://github.com/vrtmrz)).
|
||||
|
||||
### Improved
|
||||
|
||||
- New Translation: `es` (Spanish) by @zeedif (Thank you so much)!
|
||||
|
||||
Reference in New Issue
Block a user