Compare commits

..

10 Commits

Author SHA1 Message Date
adrian-fuertes
34db181af0
fix typos in sync messages and comments (startting -> starting) (#876)
Some checks failed
BuildCI / build (20.x) (push) Failing after 5m56s
2024-11-10 18:16:22 +08:00
Liam Swayne
6631a9c5eb
typo fixes (#870) 2024-11-10 18:14:16 +08:00
fyears
e39edcea70 bump to 0.5.25
Some checks failed
Release A New Version / build (20.x) (push) Failing after 46s
2024-10-20 17:12:42 +08:00
fyears
9ac7ecf828 fix undefined 2024-10-20 16:58:22 +08:00
fyears
50c08400ff add more prefix 2024-10-20 16:42:47 +08:00
fyears
7bc2fad88b bump to 0.5.24
Some checks failed
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
Some checks failed
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
12 changed files with 162 additions and 37 deletions

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**.

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 名称本身未加密**。

View File

@ -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!

View File

@ -1,7 +1,7 @@
{
"id": "remotely-save",
"name": "Remotely Save",
"version": "0.5.22",
"version": "0.5.25",
"minAppVersion": "0.13.21",
"description": "Yet another unofficial plugin allowing users to synchronize notes between local device and the cloud service.",
"author": "fyears",

View File

@ -1,7 +1,7 @@
{
"id": "remotely-save",
"name": "Remotely Save",
"version": "0.5.22",
"version": "0.5.25",
"minAppVersion": "0.13.21",
"description": "Yet another unofficial plugin allowing users to synchronize notes between local device and the cloud service.",
"author": "fyears",

View File

@ -1,6 +1,6 @@
{
"name": "remotely-save",
"version": "0.5.22",
"version": "0.5.25",
"description": "This is yet another sync plugin for Obsidian app.",
"scripts": {
"dev2": "node esbuild.config.mjs --watch",

View File

@ -268,7 +268,7 @@
"settings_azureblobstorage_parts": "Parts Concurrency",
"settings_azureblobstorage_parts_desc": "Large files are split into small parts to upload. How many parts do you want to upload in parallel at most?",
"settings_azureblobstorage_generatefolderobject": "Generate Folder Object Or Not",
"settings_azureblobstorage_generatefolderobject_desc": "Azure Blob Storage doesn't have \"real\" folder. If you set \"Generate\" here, the plugin will upload a zero-byte object endding with \"/\" to represent the folder. By default, the plugin skips generating folder object.",
"settings_azureblobstorage_generatefolderobject_desc": "Azure Blob Storage doesn't have \"real\" folder. If you set \"Generate\" here, the plugin will upload a zero-byte object ending with \"/\" to represent the folder. By default, the plugin skips generating folder object.",
"settings_azureblobstorage_generatefolderobject_notgenerate": "Not generate (default)",
"settings_azureblobstorage_generatefolderobject_generate": "Generate",
"settings_azureblobstorage_connect_succ": "Great! We can connect to Azure Blob Storage!",

View File

@ -203,21 +203,36 @@ export const checkIsSkipItemOrNotByName = (
}
}
// we have to check bookmarks.json firstly then check the whole .obsidian folder later
if (isBookmarksFile(key, configDir) && finalIsIgnored === undefined) {
if (syncBookmarks) {
finalIsIgnored = false;
} else {
finalIsIgnored = true;
}
}
// we have to check bookmarks.json firstly then check the whole .obsidian folder later
if (isInsideObsFolder(key, configDir) && finalIsIgnored === undefined) {
// 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
}
}
}
@ -290,7 +305,14 @@ export const getSkipItemsByList = (
}
// we deal with explictly allow list secondly, apply them to PARENTS if possible
const enableAllowMode = skipOrNotResults[allPotentialKeys[0]].enableAllowMode;
let enableAllowMode = false;
if (
allPotentialKeys.length > 0 &&
allPotentialKeys[0] !== undefined &&
skipOrNotResults[allPotentialKeys[0]] !== undefined
) {
enableAllowMode = skipOrNotResults[allPotentialKeys[0]].enableAllowMode;
}
if (enableAllowMode) {
for (let index = 0; index < sortedKeys.length; index++) {
// reverse order, long(deep) to short(shadow), ascending
@ -1908,7 +1930,7 @@ export async function syncer(
) => any,
callbackSyncProcess?: any
) {
console.info(`startting sync.`);
console.info(`starting sync.`);
markIsSyncingFunc(true);
let everythingOk = true;
@ -2067,6 +2089,6 @@ export async function syncer(
await ribboonFunc?.(triggerSource, step);
await statusBarFunc?.(triggerSource, step, everythingOk);
console.info(`endding sync.`);
console.info(`ending sync.`);
markIsSyncingFunc(false);
}

View File

@ -252,6 +252,10 @@ const fromDriveItemToEntity = (x: DriveItem, remoteBaseDir: string): Entity => {
// why?? /drive/root:/Apps/Graph
const FIFTH_COMMON_PREFIX_REGEX = /^\/drive\/root:\/[^\/]+\/Graph\//g;
// why again?? /drive/root:/Apps/Graph 1
const SIXTH_COMMON_PREFIX_REGEX = /^\/drive\/root:\/[^\/]+\/Graph 1\//g;
const SIXTH_COMMON_PREFIX_REGEX_V2 = /^\/drive\/root:\/[^\/]+\/Graph%201\//g;
// or the root is absolute path /Livefolders,
// e.g.: /Livefolders/应用/remotely-save/${remoteBaseDir}
const SECOND_COMMON_PREFIX_REGEX = /^\/Livefolders\/[^\/]+\/remotely-save\//g;
@ -278,6 +282,11 @@ const fromDriveItemToEntity = (x: DriveItem, remoteBaseDir: string): Entity => {
const fullPathOriginal = `${x.parentReference.path}/${x.name}`;
const matchFirstPrefixRes = fullPathOriginal.match(FIRST_COMMON_PREFIX_REGEX);
const matchFifthPrefixRes = fullPathOriginal.match(FIFTH_COMMON_PREFIX_REGEX);
const matchSixthPrefixRes = fullPathOriginal.match(SIXTH_COMMON_PREFIX_REGEX);
const matchSixthV2PrefixRes = fullPathOriginal.match(
SIXTH_COMMON_PREFIX_REGEX_V2
);
const matchSecondPrefixRes = fullPathOriginal.match(
SECOND_COMMON_PREFIX_REGEX
);
@ -317,6 +326,40 @@ const fromDriveItemToEntity = (x: DriveItem, remoteBaseDir: string): Entity => {
key = fullPathOriginal.substring(foundPrefix.length + 1);
}
// sixth
else if (
matchSixthPrefixRes !== null &&
fullPathOriginal.startsWith(`${matchSixthPrefixRes[0]}${remoteBaseDir}`)
) {
const foundPrefix = `${matchSixthPrefixRes[0]}${remoteBaseDir}`;
key = fullPathOriginal.substring(foundPrefix.length + 1);
} else if (
matchSixthPrefixRes !== null &&
fullPathOriginal.startsWith(
`${matchSixthPrefixRes[0]}${remoteBaseDirEncoded}`
)
) {
const foundPrefix = `${matchSixthPrefixRes[0]}${remoteBaseDirEncoded}`;
key = fullPathOriginal.substring(foundPrefix.length + 1);
}
// sixth v2
else if (
matchSixthV2PrefixRes !== null &&
fullPathOriginal.startsWith(`${matchSixthV2PrefixRes[0]}${remoteBaseDir}`)
) {
const foundPrefix = `${matchSixthV2PrefixRes[0]}${remoteBaseDir}`;
key = fullPathOriginal.substring(foundPrefix.length + 1);
} else if (
matchSixthV2PrefixRes !== null &&
fullPathOriginal.startsWith(
`${matchSixthV2PrefixRes[0]}${remoteBaseDirEncoded}`
)
) {
const foundPrefix = `${matchSixthV2PrefixRes[0]}${remoteBaseDirEncoded}`;
key = fullPathOriginal.substring(foundPrefix.length + 1);
}
// second
else if (
matchSecondPrefixRes !== null &&
@ -374,6 +417,8 @@ const fromDriveItemToEntity = (x: DriveItem, remoteBaseDir: string): Entity => {
fullPathOriginal=${fullPathOriginal}
matchFirstPrefixRes=${matchFirstPrefixRes}
matchFifthPrefixRes=${matchFifthPrefixRes}
matchSixthPrefixRes=${matchSixthPrefixRes}
matchSixthV2PrefixRes=${matchSixthV2PrefixRes}
matchSecondPrefixRes=${matchSecondPrefixRes}
matchThirdPrefixRes=${matchThirdPrefixRes}
${constructFromDriveItemToEntityError(x)}`
@ -388,6 +433,8 @@ ${constructFromDriveItemToEntityError(x)}`
fullPathOriginal=${fullPathOriginal}
matchFirstPrefixRes=${matchFirstPrefixRes}
matchFifthPrefixRes=${matchFifthPrefixRes}
matchSixthPrefixRes=${matchSixthPrefixRes}
matchSixthV2PrefixRes=${matchSixthV2PrefixRes}
matchSecondPrefixRes=${matchSecondPrefixRes}
matchThirdPrefixRes=${matchThirdPrefixRes}
${constructFromDriveItemToEntityError(x)}`

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> {

View File

@ -31,7 +31,7 @@
"protocol_dropbox_connect_succ_revoke": "You've connected as user {{username}}. If you want to disconnect, click this button.",
"protocol_dropbox_connect_fail": "Something went wrong from response from Dropbox. Maybe the network connection is not good. Maybe you rejected the auth?",
"protocol_dropbox_connect_unknown": "Do not know how to deal with the callback: {{params}}",
"protocol_dropbox_no_modal": "You are not startting Dropbox connection from the settings page. Abort.",
"protocol_dropbox_no_modal": "You are not starting Dropbox connection from the settings page. Abort.",
"protocol_onedrive_connecting": "Connecting to OneDrive...\nPlease DO NOT close this modal.",
"protocol_onedrive_connect_succ_revoke": "You've connected as user {{username}}. If you want to disconnect, click this button.",
"protocol_onedrive_connect_fail": "Something went wrong from response from OneDrive. Maybe you rejected the auth?",
@ -110,7 +110,7 @@
"modal_onedriverevokeauth_clean_button": "Clean",
"modal_onedriverevokeauth_clean_notice": "Cleaned!",
"modal_onedriverevokeauth_clean_fail": "Something goes wrong while revoking.",
"modal_syncconfig_attn": "Attention 1/2: This only syncs (copies) the whole Obsidian config dir, not other startting-with-dot folders or files. Except for ignoring folders .git and node_modules, it also doesn't understand the meaning of sub-files and sub-folders inside the config dir.\nAttention 2/2: After the config dir is synced, plugins settings might be corrupted, and Obsidian might need to be restarted to load the new settings.\nIf you are agreed to take your own risk, please click the following second confirm button.",
"modal_syncconfig_attn": "Attention 1/2: This only syncs (copies) the whole Obsidian config dir, not other starting-with-dot folders or files. Except for ignoring folders .git and node_modules, it also doesn't understand the meaning of sub-files and sub-folders inside the config dir.\nAttention 2/2: After the config dir is synced, plugins settings might be corrupted, and Obsidian might need to be restarted to load the new settings.\nIf you are agreed to take your own risk, please click the following second confirm button.",
"modal_syncconfig_secondconfirm": "The Second Confirm To Enable.",
"modal_syncconfig_notice": "You've enabled syncing config folder!",
"modal_qr_shortdesc": "This exports (partial) settings.\nYou can use another device to scan this qrcode.\nOr, you can click the button to copy the special uri and paste it into another device's web browser or Remotely Save Import Setting.",
@ -194,7 +194,7 @@
"settings_s3_reverse_proxy_no_sign_url": "S3 Reverse Proxy (No Sign) Url (experimental)",
"settings_s3_reverse_proxy_no_sign_url_desc": "S3 reverse proxy url without signature. This is useful if you use a revers proxy but do not change the original credential signature. No http(s):// prefix. Leave it blank if you don't know what it is.",
"settings_s3_generatefolderobject": "Generate Folder Object Or Not",
"settings_s3_generatefolderobject_desc": "S3 doesn't have \"real\" folder. If you set \"Generate\" here (or use old version), the plugin will upload a zero-byte object endding with \"/\" to represent the folder. In the new version, the plugin skips generating folder object by default.",
"settings_s3_generatefolderobject_desc": "S3 doesn't have \"real\" folder. If you set \"Generate\" here (or use old version), the plugin will upload a zero-byte object ending with \"/\" to represent the folder. In the new version, the plugin skips generating folder object by default.",
"settings_s3_generatefolderobject_notgenerate": "Not generate (default)",
"settings_s3_generatefolderobject_generate": "Generate",
"settings_s3_connect_succ": "Great! The bucket can be accessed.",

View File

@ -279,7 +279,7 @@ export const reverseString = (x: string) => {
};
export interface SplitRange {
partNum: number; // startting from 1
partNum: number; // starting from 1
start: number;
end: number; // exclusive
}
@ -316,7 +316,7 @@ export const getTypeName = (obj: any) => {
};
/**
* Startting from 1
* starting from 1
* @param x
* @returns
*/