Compare commits

..
13 Commits
Author SHA1 Message Date
fyears 7bc2fad88b bump to 0.5.24
Release A New Version / build (20.x) (push) Failing after 41s
2024-09-30 21:15:53 +08:00
fyears 6dc1c28361 add caddy 2024-09-30 21:15:23 +08:00
fyears 2220f511e3 fix webdav path with /.. leading 2024-09-30 20:51:55 +08:00
fyears 06de1a4ab0 bump to 0.5.23
Release A New Version / build (20.x) (push) Failing after 47s
2024-09-30 18:11:43 +08:00
fyears df184ff9d8 correct way to deal with .obsidian and bookmarks 2024-09-30 18:11:08 +08:00
fyears f50ba953f1 fix ci
Release A New Version / build (20.x) (push) Failing after 50s
2024-09-29 10:19:48 +08:00
fyears 55cb26bd22 bump to 0.5.22 2024-09-29 10:11:01 +08:00
fyears 36d3018efb fix ignore logic 2024-09-29 10:09:49 +08:00
fyears 421b43d937 update complex logic for config 2024-09-29 09:32:04 +08:00
xvqinghong 17708359a1 fix bug of unwished synchronizing Config Directory and Bookmarks File (#816)
In the original code, if we set syncConfigDir to false, which means we don't want to sync this directory, but it will also cause `if( syncConfigDir && isInsideObsFolder(key, configDir) )` statement NEVER be entered.  Thus, in the original code, our setting is actually be ignored.
2024-09-29 09:20:27 +08:00
fyears 9acae1b077 fix google drive expire 2024-09-29 08:59:14 +08:00
fyears 4ade975585 warn in console about expire 2024-09-29 08:58:57 +08:00
fyears e988fc7ae9 update ci 2024-09-09 00:39:19 +08:00
12 changed files with 186 additions and 93 deletions
+3 -3
View File
@@ -39,13 +39,13 @@ jobs:
steps:
- name: Checkout codes
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
- name: Checkout LFS file list
run: git lfs ls-files --long | cut -d ' ' -f1 | sort > .lfs-assets-id
- name: LFS Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .git/lfs/objects
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
@@ -60,7 +60,7 @@ jobs:
- run: npm install
- run: npm test
- run: npm run build
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: my-dist
path: |
+11 -41
View File
@@ -42,13 +42,13 @@ jobs:
steps:
- name: Checkout codes
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
- name: Checkout LFS file list
run: git lfs ls-files --long | cut -d ' ' -f1 | sort > .lfs-assets-id
- name: LFS Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .git/lfs/objects
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
@@ -63,44 +63,14 @@ jobs:
- run: npm install
- run: npm test
- run: npm run build
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ github.ref }}
- name: Create Release And Upload
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
files: |
main.js
manifest.json
styles.css
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: true
- name: Upload main.js
id: upload-main
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./main.js
asset_name: main.js
asset_content_type: text/javascript
- name: Upload manifest.json
id: upload-manifest
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./manifest.json
asset_name: manifest.json
asset_content_type: application/json
- name: Upload styles.css
id: upload-styles
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./styles.css
asset_name: styles.css
asset_content_type: text/css
prerelease: false
make_latest: true
+1
View File
@@ -122,6 +122,7 @@ Additionally, the plugin author may occasionally visit Obsidian official forum a
- [Open Media Vault](./docs/remote_services/webdav_openmediavault/README.md)
- [Nginx (`ngx_http_dav_module`, `nginx-dav-ext-module`, with Docker)](./docs/remote_services/webdav_nginx/README.md)
- [Apache (with Docker)](./docs/remote_services/webdav_apache/README.md)
- [Caddy with `http.handlers.webdav` module](./docs/remote_services/webdav_caddy/README.md)
- Very old version of Obsidian needs [configuring CORS](./docs/remote_services/webdav_general/webav_cors.md).
- Your data would be synced to a `${vaultName}` sub folder on your webdav server.
- Password-based end-to-end encryption is also supported. But please be aware that **the vault name itself is not encrypted**.
+1
View File
@@ -122,6 +122,7 @@
- [Open Media Vault](./docs/remote_services/webdav_openmediavault/README.md)
- [Nginx (`ngx_http_dav_module`, `nginx-dav-ext-module`, with Docker)](./docs/remote_services/webdav_nginx/README.md)
- [Apache (with Docker)](./docs/remote_services/webdav_apache/README.md)
- [Caddy with `http.handlers.webdav` module](./docs/remote_services/webdav_caddy/README.md)
- 非常旧版本的Obsidian需要[配置 CORS](./docs/remote_services/webdav_general/webav_cors.md)。
- 你的数据会同步到你的webdav服务器上的 `${vaultName}` 子文件夹。
- 基于密码的端到端加密也是可以的。但请注意,**vault 名称本身未加密**。
@@ -0,0 +1,33 @@
# Caddy with `http.handlers.webdav` module
> modified from the instruction from @cyruz-git in https://github.com/remotely-save/remotely-save/issues/825
## Link
<https://caddyserver.com/download?package=github.com%2Fmholt%2Fcaddy-webdav>
## Steps
1. Download caddy with webdav module from <https://caddyserver.com/download?package=github.com%2Fmholt%2Fcaddy-webdav>. Or you can install Caddy then install the plugins.
2. Create a folder for storing webdav server files. Like `/usr/local/mywebdav`.
3. Create a `Caddyfile` (yeah the file name itself is `Caddyfile`.) like this:
```caddy
:8080 {
route /dav/* {
root /usr/local/mywebdav
basicauth {
# Username "Bob", password "hiccup"
Bob $2a$14$Zkx19XLiW6VYouLHR5NmfOFU0z2GTNmpkT/5qqR7hx4IjWJPDhjvG
}
uri strip_prefix /dav
webdav
}
}
```
The password hash is generated like [this](https://caddyserver.com/docs/caddyfile/directives/basic_auth).
4. In Remotely Save, setup:
* address `http://localhost:8080/dav/`
* username `Bob`
* password `hiccup`
* auth type: `basic`
5. Check the connection and sync!
+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "remotely-save",
"name": "Remotely Save",
"version": "0.5.21",
"version": "0.5.24",
"minAppVersion": "0.13.21",
"description": "Yet another unofficial plugin allowing users to synchronize notes between local device and the cloud service.",
"author": "fyears",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "remotely-save",
"name": "Remotely Save",
"version": "0.5.21",
"version": "0.5.24",
"minAppVersion": "0.13.21",
"description": "Yet another unofficial plugin allowing users to synchronize notes between local device and the cloud service.",
"author": "fyears",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "remotely-save",
"version": "0.5.21",
"version": "0.5.24",
"description": "This is yet another sync plugin for Obsidian app.",
"scripts": {
"dev2": "node esbuild.config.mjs --watch",
+4
View File
@@ -95,6 +95,10 @@ class GoogleDriveAuthModal extends Modal {
k.expires_in * 1000;
this.plugin.settings.googledrive.accessTokenExpiresAtTimeMs =
ts + k.expires_in * 1000 - 60 * 2 * 1000;
// manually set it expired after 60 days;
this.plugin.settings.googledrive.credentialsShouldBeDeletedAtTimeMs =
Date.now() + 1000 * 60 * 60 * 24 * 59;
await this.plugin.saveSettings();
// try to remove data in clipboard
+89 -34
View File
@@ -202,15 +202,37 @@ export const checkIsSkipItemOrNotByName = (
}
}
}
if (syncConfigDir && isInsideObsFolder(key, configDir)) {
if (finalIsIgnored === undefined) {
finalIsIgnored = false;
}
}
if (syncBookmarks && isBookmarksFile(key, configDir)) {
if (finalIsIgnored === undefined) {
finalIsIgnored = false;
// sync config, not sync bookmarks: sync config and **force syncing bookmarks as well**
// not sync config, sync bookmarks: sync bookmars, not other config
// not sync config, not sync bookmarks: not sync config
if (finalIsIgnored === undefined) {
if (syncConfigDir) {
if (isInsideObsFolder(key, configDir)) {
// force sync everything
finalIsIgnored = false;
} else {
// not config files, do not judge now, do nothing
}
} else if (syncBookmarks) {
// not sync config, sync bookmarks
if (isBookmarksFile(key, configDir)) {
// sync everything of bookmarks
finalIsIgnored = false;
} else if (isInsideObsFolder(key, configDir)) {
// not sync any other thing in config
finalIsIgnored = true;
} else {
// not config files, do not judge now, do nothing
}
} else {
// not sync config, and not sync bookmarks
if (isInsideObsFolder(key, configDir)) {
// not sync any thing in config
finalIsIgnored = true;
} else {
// not config files, do not judge now, do nothing
}
}
}
@@ -256,17 +278,9 @@ export const checkIsSkipItemOrNotByName = (
* | yes, also apply to children | explictly ignored | yes | yes | yes |
*/
export const getSkipItemsByList = (
skipOrNotResults: Record<string, IsSkipResult>,
ignorePaths: string[],
onlyAllowPaths: string[]
skipOrNotResults: Record<string, IsSkipResult>
): string[] => {
const allPotentialKeys = Object.keys(skipOrNotResults);
if (
allPotentialKeys.length === 0 ||
(ignorePaths.length === 0 && onlyAllowPaths.length === 0)
) {
return [];
}
// from short(shadow) to long(deep) , ascending
const sortedKeys = allPotentialKeys.sort((k1, k2) => k1.length - k2.length);
@@ -329,6 +343,7 @@ export const getSkipItemsByList = (
result.push(key);
}
}
console.debug(`finalIsIgnored list= ${JSON.stringify(result)}`);
return result;
};
@@ -495,11 +510,7 @@ const ensembleMixedEnties = async (
profiler?.insertSize("sizeof finalMappings", finalMappings);
// we check the skipOrNotResults again! in case we adjust some paths!
const allReallySkipKeys = getSkipItemsByList(
skipOrNotResults,
ignorePaths,
onlyAllowPaths
);
const allReallySkipKeys = getSkipItemsByList(skipOrNotResults);
for (const key of allReallySkipKeys) {
delete finalMappings[key];
}
@@ -625,14 +636,36 @@ const getSyncPlanInplace = async (
mixedEntry.change = false;
keptFolder.add(getParentFolder(key));
} else if (syncDirection === "incremental_pull_and_delete_only") {
mixedEntry.decisionBranch = 135;
mixedEntry.decision = "folder_to_be_deleted_on_local";
mixedEntry.change = true;
if (
key === `${configDir}/` ||
key === `${configDir}/bookmarks.json`
) {
// special: never delete .obsidian folder!
mixedEntry.decisionBranch = 137;
mixedEntry.decision = "folder_existed_both_then_do_nothing";
mixedEntry.change = false;
keptFolder.add(getParentFolder(key));
} else {
mixedEntry.decisionBranch = 135;
mixedEntry.decision = "folder_to_be_deleted_on_local";
mixedEntry.change = true;
}
} else {
// bidirectional
mixedEntry.decisionBranch = 124;
mixedEntry.decision = "folder_to_be_deleted_on_local";
mixedEntry.change = true;
if (
key === `${configDir}/` ||
key === `${configDir}/bookmarks.json`
) {
// special: never delete .obsidian folder!
mixedEntry.decisionBranch = 138;
mixedEntry.decision = "folder_existed_both_then_do_nothing";
mixedEntry.change = false;
keptFolder.add(getParentFolder(key));
} else {
mixedEntry.decisionBranch = 124;
mixedEntry.decision = "folder_to_be_deleted_on_local";
mixedEntry.change = true;
}
}
} else {
// then the folder is created on local
@@ -1074,13 +1107,35 @@ const getSyncPlanInplace = async (
mixedEntry.decision = "conflict_created_then_do_nothing";
mixedEntry.change = false;
} else if (syncDirection === "incremental_pull_and_delete_only") {
mixedEntry.decisionBranch = 39;
mixedEntry.decision = "remote_is_deleted_thus_also_delete_local";
mixedEntry.change = true;
if (
key === `${configDir}/` ||
key === `${configDir}/bookmarks.json`
) {
// special: never delete .obsidian/bookmarks.json file!
mixedEntry.decisionBranch = 139;
mixedEntry.decision = "conflict_created_then_keep_local";
mixedEntry.change = true;
keptFolder.add(getParentFolder(key));
} else {
mixedEntry.decisionBranch = 39;
mixedEntry.decision = "remote_is_deleted_thus_also_delete_local";
mixedEntry.change = true;
}
} else {
mixedEntry.decisionBranch = 7;
mixedEntry.decision = "remote_is_deleted_thus_also_delete_local";
mixedEntry.change = true;
if (
key === `${configDir}/` ||
key === `${configDir}/bookmarks.json`
) {
// special: never delete .obsidian/bookmarks.json file!
mixedEntry.decisionBranch = 140;
mixedEntry.decision = "conflict_created_then_keep_local";
mixedEntry.change = true;
keptFolder.add(getParentFolder(key));
} else {
mixedEntry.decisionBranch = 7;
mixedEntry.decision = "remote_is_deleted_thus_also_delete_local";
mixedEntry.change = true;
}
}
} else {
// if A is in the previous list and MODIFIED, A has been deleted by B but modified by A
+33 -12
View File
@@ -138,7 +138,6 @@ if (VALID_REQURL) {
);
}
import isEqual from "lodash/isEqual";
// @ts-ignore
// biome-ignore lint: we want to ts-ignore the next line
import { AuthType, BufferLike, createClient } from "webdav/dist/web/index.js";
@@ -169,23 +168,37 @@ const getWebdavPath = (fileOrFolderPath: string, remoteBaseDir: string) => {
return key;
};
/**
* sometimes the path startswith /../../......
* we want to make sure the path is compatible
*/
const stripLeadingPath = (x: string) => {
let y = x;
while (y.startsWith("/..")) {
y = y.slice("/..".length);
}
return y;
};
const getNormPath = (fileOrFolderPath: string, remoteBaseDir: string) => {
const strippedFileOrFolderPath = stripLeadingPath(fileOrFolderPath);
if (
!(
fileOrFolderPath === `/${remoteBaseDir}` ||
fileOrFolderPath.startsWith(`/${remoteBaseDir}/`)
strippedFileOrFolderPath === `/${remoteBaseDir}` ||
strippedFileOrFolderPath.startsWith(`/${remoteBaseDir}/`)
)
) {
throw Error(
`"${fileOrFolderPath}" doesn't starts with "/${remoteBaseDir}/"`
`"${fileOrFolderPath}" after stripping doesn't starts with "/${remoteBaseDir}/"`
);
}
return fileOrFolderPath.slice(`/${remoteBaseDir}/`.length);
const result = strippedFileOrFolderPath.slice(`/${remoteBaseDir}/`.length);
return result;
};
const fromWebdavItemToEntity = (x: FileStat, remoteBaseDir: string): Entity => {
let key = getNormPath(x.filename, remoteBaseDir);
if (x.type === "directory" && !key.endsWith("/")) {
key = `${key}/`;
}
@@ -447,15 +460,17 @@ export class FakeFsWebdav extends FakeFs {
// console.debug(itemsToFetchChunks);
const subContents = [] as FileStat[];
for (const singleChunk of itemsToFetchChunks) {
const r = singleChunk.map((x) => {
return this.client.getDirectoryContents(x, {
const r = singleChunk.map(async (x) => {
let k = (await this.client.getDirectoryContents(x, {
deep: false,
details: false /* no need for verbose details here */,
// TODO: to support .obsidian,
// we need to load all files including dot,
// anyway to reduce the resources?
// glob: "/**" /* avoid dot files by using glob */,
}) as Promise<FileStat[]>;
})) as FileStat[];
k = k.filter((sub) => stripLeadingPath(sub.filename) !== x);
return k;
});
const r3 = await Promise.all(r);
for (const r4 of r3) {
@@ -477,7 +492,7 @@ export class FakeFsWebdav extends FakeFs {
const f = subContents[i];
contents.push(f);
if (f.type === "directory") {
q.push(f.filename);
q.push(stripLeadingPath(f.filename));
}
}
}
@@ -495,7 +510,11 @@ export class FakeFsWebdav extends FakeFs {
}
)) as FileStat[];
}
return contents.map((x) => fromWebdavItemToEntity(x, this.remoteBaseDir));
const result = contents
.map((x) => fromWebdavItemToEntity(x, this.remoteBaseDir))
.filter((x) => x.keyRaw !== "/");
return result;
}
async walkPartial(): Promise<Entity[]> {
@@ -508,7 +527,9 @@ export class FakeFsWebdav extends FakeFs {
details: false /* no need for verbose details here */,
}
)) as FileStat[];
return contents.map((x) => fromWebdavItemToEntity(x, this.remoteBaseDir));
return contents
.map((x) => fromWebdavItemToEntity(x, this.remoteBaseDir))
.filter((x) => x.keyRaw !== "/");
}
async stat(key: string): Promise<Entity> {
+8
View File
@@ -1560,6 +1560,7 @@ export default class RemotelySavePlugin extends Plugin {
this.settings.dropbox.refreshToken !== "" &&
current >= this.settings!.dropbox!.credentialsShouldBeDeletedAtTime!
) {
console.warn(`dropbox expired`);
dropboxExpired = true;
this.settings.dropbox = cloneDeep(DEFAULT_DROPBOX_CONFIG);
needSave = true;
@@ -1570,6 +1571,7 @@ export default class RemotelySavePlugin extends Plugin {
this.settings.onedrive.refreshToken !== "" &&
current >= this.settings!.onedrive!.credentialsShouldBeDeletedAtTime!
) {
console.warn(`onedrive expired`);
onedriveExpired = true;
this.settings.onedrive = cloneDeep(DEFAULT_ONEDRIVE_CONFIG);
needSave = true;
@@ -1580,6 +1582,7 @@ export default class RemotelySavePlugin extends Plugin {
this.settings.onedrivefull.refreshToken !== "" &&
current >= this.settings!.onedrivefull!.credentialsShouldBeDeletedAtTime!
) {
console.warn(`onedrive full expired`);
onedriveFullExpired = true;
this.settings.onedrivefull = cloneDeep(DEFAULT_ONEDRIVEFULL_CONFIG);
needSave = true;
@@ -1590,6 +1593,7 @@ export default class RemotelySavePlugin extends Plugin {
this.settings.googledrive.refreshToken !== "" &&
current >= this.settings!.googledrive!.credentialsShouldBeDeletedAtTimeMs!
) {
console.warn(`google drive expired`);
googleDriveExpired = true;
this.settings.googledrive = cloneDeep(DEFAULT_GOOGLEDRIVE_CONFIG);
needSave = true;
@@ -1600,6 +1604,7 @@ export default class RemotelySavePlugin extends Plugin {
this.settings.box.refreshToken !== "" &&
current >= this.settings!.box!.credentialsShouldBeDeletedAtTimeMs!
) {
console.warn(`box expired`);
boxExpired = true;
this.settings.box = cloneDeep(DEFAULT_BOX_CONFIG);
needSave = true;
@@ -1610,6 +1615,7 @@ export default class RemotelySavePlugin extends Plugin {
this.settings.pcloud.accessToken !== "" &&
current >= this.settings!.pcloud!.credentialsShouldBeDeletedAtTimeMs!
) {
console.warn(`pcloud expired`);
pCloudExpired = true;
this.settings.pcloud = cloneDeep(DEFAULT_PCLOUD_CONFIG);
needSave = true;
@@ -1620,6 +1626,7 @@ export default class RemotelySavePlugin extends Plugin {
this.settings.yandexdisk.refreshToken !== "" &&
current >= this.settings!.yandexdisk!.credentialsShouldBeDeletedAtTimeMs!
) {
console.warn(`yandex disk expired`);
yandexDiskExpired = true;
this.settings.yandexdisk = cloneDeep(DEFAULT_YANDEXDISK_CONFIG);
needSave = true;
@@ -1630,6 +1637,7 @@ export default class RemotelySavePlugin extends Plugin {
this.settings.koofr.refreshToken !== "" &&
current >= this.settings!.koofr!.credentialsShouldBeDeletedAtTimeMs!
) {
console.warn(`koofr expired`);
koofrExpired = true;
this.settings.koofr = cloneDeep(DEFAULT_KOOFR_CONFIG);
needSave = true;