Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
480cf224c6 | ||
|
|
37a801332f | ||
|
|
1e33f8b7d2 | ||
|
|
071b10387c | ||
|
|
b99053ef10 | ||
|
|
ff237ad8cb | ||
|
|
b89a163a66 | ||
|
|
991376a7a3 | ||
|
|
2da39bdfec | ||
|
|
f38c3d36be | ||
|
|
da0f183fad | ||
|
|
eb2ecca825 | ||
|
|
2494a2d96e | ||
|
|
8bb095c4aa | ||
|
|
c5e3147805 | ||
|
|
942e54961e | ||
|
|
29a3c76b4e | ||
|
|
897e4fc4e5 | ||
|
|
0124a49d7e | ||
|
|
3e245af50c | ||
|
|
695c74588f | ||
|
|
e3bd41a05a | ||
|
|
a6b73bde6a | ||
|
|
87d6e1f75f | ||
|
|
347c051d0c | ||
|
|
7422956621 | ||
|
|
7b67ba5b26 | ||
|
|
43cf95c417 | ||
|
|
53a1c32b43 | ||
|
|
71e25be28e | ||
|
|
afc5670313 | ||
|
|
81eb45d32c | ||
|
|
d7a59b82be |
@@ -31,13 +31,30 @@ body:
|
||||
- type: dropdown
|
||||
id: service
|
||||
attributes:
|
||||
label: What remote cloud services are you using?
|
||||
label: What remote cloud services are you using? (Please choose the specified one if it's in the list)
|
||||
multiple: true
|
||||
options:
|
||||
- S3
|
||||
- S3 (Cloudflare R2)
|
||||
- S3 (BackBlaze B2)
|
||||
- S3 (腾讯云 COS Tencent Cloud COS)
|
||||
- S3 (阿里云 OSS Alibaba Cloud OSS)
|
||||
- S3 (MinIO)
|
||||
- S3 (Wasabi)
|
||||
- S3 (Storj)
|
||||
- OneDrive for personal
|
||||
- OneDrive for business
|
||||
- Dropbox
|
||||
- webdav
|
||||
- webdav (ownCloud)
|
||||
- webdav (InfiniCloud (formally TeraCLOUD))
|
||||
- webdav (AList)
|
||||
- webdav (Cloudreve)
|
||||
- webdav (坚果云 JianGuoYun/NutStore)
|
||||
- webdav (NextCloud)
|
||||
- webdav (FastMail)
|
||||
- webdav (rclone webdav)
|
||||
- webdav (nginx)
|
||||
- others
|
||||
validations:
|
||||
required: true
|
||||
|
||||
@@ -21,9 +21,26 @@ body:
|
||||
multiple: true
|
||||
options:
|
||||
- S3
|
||||
- S3 (Cloudflare R2)
|
||||
- S3 (BackBlaze B2)
|
||||
- S3 (腾讯云 COS Tencent Cloud COS)
|
||||
- S3 (阿里云 OSS Alibaba Cloud OSS)
|
||||
- S3 (MinIO)
|
||||
- S3 (Wasabi)
|
||||
- S3 (Storj)
|
||||
- OneDrive for personal
|
||||
- OneDrive for business
|
||||
- Dropbox
|
||||
- webdav
|
||||
- webdav (ownCloud)
|
||||
- webdav (InfiniCloud (formally TeraCLOUD))
|
||||
- webdav (AList)
|
||||
- webdav (Cloudreve)
|
||||
- webdav (坚果云 JianGuoYun/NutStore)
|
||||
- webdav (NextCloud)
|
||||
- webdav (FastMail)
|
||||
- webdav (rclone webdav)
|
||||
- webdav (nginx)
|
||||
- others
|
||||
validations:
|
||||
required: false
|
||||
|
||||
@@ -17,7 +17,7 @@ This is yet another unofficial sync plugin for Obsidian. If you like it or find
|
||||
## Features
|
||||
|
||||
- Supports:
|
||||
- Amazon S3 or S3-compatible
|
||||
- Amazon S3 or S3-compatible (Cloudflare R2 / BackBlaze B2 / MinIO / ...)
|
||||
- Dropbox
|
||||
- OneDrive for personal
|
||||
- Webdav
|
||||
@@ -26,7 +26,7 @@ This is yet another unofficial sync plugin for Obsidian. If you like it or find
|
||||
- **[End-to-end encryption](./docs/encryption.md) supported.** Files would be encrypted using openssl format before being sent to the cloud **if** user specify a password.
|
||||
- **Scheduled auto sync supported.** You can also manually trigger the sync using sidebar ribbon, or using the command from the command palette (or even bind the hot key combination to the command then press the hot key combination).
|
||||
- **[Minimal Intrusive](./docs/minimal_intrusive_design.md).**
|
||||
- \*\*Skip Large files and skip paths by custom regex conditions!
|
||||
- **Skip Large files** and **skip paths** by custom regex conditions!
|
||||
- **Fully open source under [Apache-2.0 License](./LICENSE).**
|
||||
- **[Sync Algorithm open](./docs/sync_algorithm_v2.md) for discussion.**
|
||||
|
||||
@@ -63,6 +63,8 @@ Additionally, the plugin author may occasionally visit Obsidian official forum a
|
||||
|
||||
- Tutorials / Examples:
|
||||
- [Cloudflare R2](./docs/remote_services/s3_cloudflare_r2/README.md)
|
||||
- [BackBlaze B2](./docs/remote_services/s3_backblaze_b2/README.md)
|
||||
- [腾讯云 COS Tencent Cloud COS](./docs/remote_services/s3_tencent_cloud_cos/README.md)
|
||||
- [MinIO](./docs/remote_services/s3_minio/README.md)
|
||||
- Prepare your S3 (-compatible) service information: [endpoint, region](https://docs.aws.amazon.com/general/latest/gr/s3.html), [access key id, secret access key](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/getting-your-credentials.html), bucket name. The bucket should be empty and solely for syncing a vault.
|
||||
- If you are using AWS S3, create [policy and user](./docs/remote_services/s3_general/s3_user_policy.md).
|
||||
@@ -93,6 +95,7 @@ Additionally, the plugin author may occasionally visit Obsidian official forum a
|
||||
- Tutorials / Examples:
|
||||
- [ownCloud](./docs/remote_services/webdav_owncloud/README.md)
|
||||
- [InfiniCloud](./docs/remote_services/webdav_infinicloud_teracloud/README.md)
|
||||
- [AList](./docs/remote_services/webdav_alist/README.md)
|
||||
- [坚果云 JianGuoYun/NutStore](./docs/remote_services/webdav_jianguoyun/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.
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# Backblaze B2
|
||||
|
||||
## Links
|
||||
|
||||
https://www.backblaze.com/cloud-storage
|
||||
|
||||
## Steps
|
||||
|
||||
1. Create a Backblaze account [on this page](https://www.backblaze.com/cloud-storage). Credit card info _is not_ required. Backblaze B2 offers 10 GB of free storage.
|
||||
|
||||
2. Please be aware that, though B2 provides some free quota, **it may still cost you money if the usage of storage or api requests exceed a certain value!!!** Especially pay attention to the api requests!!!
|
||||
|
||||
3. Create a **bucket**, you can leave the default settings, or you can enable the encryption (which is different from what you can set in Remotely Save):
|
||||
|
||||

|
||||

|
||||
|
||||
4. Copy `Endpoint`, eg. `s3.us-east-005.backblazeb2.com` — it'll be used later.
|
||||
|
||||
5. Copy `bucketname` near the 🪣 icon (the "bucket icon") — it'll be used later.
|
||||
|
||||

|
||||
|
||||
6. Go to **Application Keys**:
|
||||
|
||||

|
||||
|
||||
7. **Add a new key**:
|
||||
|
||||

|
||||

|
||||
|
||||
8. Save `keyID` and `applicationKey` — they will be used later.
|
||||
|
||||
9. Go to Remotely Save settings in Obsidian and:
|
||||
|
||||
- Choose `S3 or compatibile` in **Remote Service**:
|
||||
- Copy `Endpoint` from Backblaze (see 3. above) to `Endpoint` in Remotely Save
|
||||
- From `endpoint` take `region` (eg. `us-east-005`) and paste it in `endpoint` in Remotely Save
|
||||
- Copy `keyID` (see 7. above) to `Access Key ID` in Remotely Save
|
||||
- Copy `applicationKey` (see 7. above) to `Secret Access Key` in Remotely Save
|
||||
- Copy `bucketname` (see 4. above) to `Bucket Name` in Remotely Save
|
||||

|
||||
|
||||
10. **Enable Bypass CORS**:
|
||||

|
||||
|
||||
11. Click **Check** in _Check Connectivity_ to see if you can connect to B2 bucket:
|
||||

|
||||
|
||||
12. Sync!
|
||||
|
||||

|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:fae18a84bb218461aca01c7de47ddadfd2b451d865ec889c098cd6918f6e8773
|
||||
size 59679
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9389f9c4462740371edb548f7e05191ede5277a5d470e3254c60fbcc4a75e552
|
||||
size 4558
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:46f35968938ebf3bbafae64ee49a4927844fd0abf79e4190522be91776d9fed0
|
||||
size 107623
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7fb639c7b4e595516594ee9d07c864e7cd15b608a97c81386f4cf72d499d0e5f
|
||||
size 80121
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:299bfca82b77de86f60d8f481b5f74069dc977dece19fa025ee629d1e6f783d4
|
||||
size 6499
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5985e918b521c91cc185f60c58cdd334ee76695b897a02e02eaa17c1bad71609
|
||||
size 10214
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5796791bcf89c99c1e1e844c0083739fd46b1a458dc274f3c3fa3f65b87b71b3
|
||||
size 70728
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3633379fcb12f1a5e0a4d1d68c193ddc7bf0be7edd92f2f6006351817035a94f
|
||||
size 27164
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9e130be182ae7d3270e5de3fec442ac5e81efd61822e844cd61ed24c7e485d39
|
||||
size 16802
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:29a8971fea065fd86223850198640f4072ee3fda2112820829cda1348f122c59
|
||||
size 11103
|
||||
@@ -0,0 +1,22 @@
|
||||
# 腾讯云 COS Tencent Cloud COS
|
||||
|
||||
## 链接 Link
|
||||
|
||||
- 中国区 <https://console.cloud.tencent.com/cos>
|
||||
- international <https://console.tencentcloud.com/cos>
|
||||
|
||||
## 步骤 Steps
|
||||
|
||||
注意这里用中国区示例,国际区配置应该类似。The example shows the steps of China version. International version should be similar.
|
||||
|
||||
1. 在“存储桶列表”页,[“创建存储桶”](https://console.cloud.tencent.com/cos/bucket?action=create)。注意创建**私有读写**,建议打开服务端加密。Create a bucket with **private read-write permissions** and recommendly enable server-side-encryption.
|
||||
2. 在桶列表页,点击刚刚存储的桶,进入概览页。可以见到桶名称(一般来说是之前指定的英文加账号数字),地域,访问域名。记录下来。In bucket list page, enter the bucket overview page of the bucket you just created. You should see the bucket name (your texts with the number of your account id), region, and access address.
|
||||

|
||||
3. 在[“访问管理页”](https://console.cloud.tencent.com/cam/capi) ,“API 密钥管理”,“创建密钥”,要记录 SecretID 和 SecretKey。In CAM page, create api key, and note down the SecretID and SecretKey.
|
||||

|
||||
4. **把桶名称从访问域名移除,才是你即将输入的服务地址!假如你在腾讯云网站看到访问域名是 `https://<bucket-name-with-number>.cos.<region>.myqcloud.com`,那么“服务地址”是 `https://cos.<region>.myqcloud.com`. Remove the bucket name from your access address to obtain your endpoint address! If your access address on the website is `https://<bucket-name-with-number>.cos.<region>.myqcloud.com`, then the endpoint address you are going to use is `https://cos.<region>.myqcloud.com`.**
|
||||
5. 在 remotely-save 设置,输入服务地址,SecretID,SecretKey,和 桶名称。In remotely-save settings page, enter your endpoint adress, SecretID, SecretKey,and bucket name.
|
||||

|
||||
6. 检查连接。Check Connectivity.
|
||||

|
||||
7. 可以同步了!Sync!
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:08b47288686c8ef8c6426776f7df52411efe431966e8f7f2f9a3a8836ee4d6c6
|
||||
size 323127
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:94c0ec5db7a75c54c36224f067659682e271aea2e61b1ee50d046cd493ba72ac
|
||||
size 58410
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f51f542756def80a77404e47f9793d1cd6917df5ab6e09d5a0ee1f7191855dc6
|
||||
size 425021
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:55064233031b44066fb7b77e17ba1eb1d0ae8398235a343cc7e137b07aaf7a39
|
||||
size 668954
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"id": "remotely-save",
|
||||
"name": "Remotely Save",
|
||||
"version": "0.3.33",
|
||||
"version": "0.3.37",
|
||||
"minAppVersion": "0.13.21",
|
||||
"description": "Yet another unofficial plugin allowing users to synchronize notes between local device and the cloud service.",
|
||||
"author": "fyears",
|
||||
"authorUrl": "https://github.com/fyears",
|
||||
"isDesktopOnly": false
|
||||
"isDesktopOnly": false,
|
||||
"fundingUrl": "https://github.com/remotely-save/donation"
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"id": "remotely-save",
|
||||
"name": "Remotely Save",
|
||||
"version": "0.3.33",
|
||||
"version": "0.3.37",
|
||||
"minAppVersion": "0.13.21",
|
||||
"description": "Yet another unofficial plugin allowing users to synchronize notes between local device and the cloud service.",
|
||||
"author": "fyears",
|
||||
"authorUrl": "https://github.com/fyears",
|
||||
"isDesktopOnly": false
|
||||
"isDesktopOnly": false,
|
||||
"fundingUrl": "https://github.com/remotely-save/donation"
|
||||
}
|
||||
|
||||
+15
-2
@@ -21,10 +21,17 @@ export interface S3Config {
|
||||
s3AccessKeyID: string;
|
||||
s3SecretAccessKey: string;
|
||||
s3BucketName: string;
|
||||
bypassCorsLocally?: boolean;
|
||||
|
||||
partsConcurrency?: number;
|
||||
forcePathStyle?: boolean;
|
||||
remotePrefix?: string;
|
||||
|
||||
useAccurateMTime?: boolean;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
bypassCorsLocally?: boolean;
|
||||
}
|
||||
|
||||
export interface DropboxConfig {
|
||||
@@ -86,7 +93,7 @@ export interface RemotelySavePluginSettings {
|
||||
syncConfigDir?: boolean;
|
||||
syncUnderscoreItems?: boolean;
|
||||
lang?: LangTypeAndAuto;
|
||||
logToDB?: boolean;
|
||||
|
||||
skipSizeLargerThan?: number;
|
||||
ignorePaths?: string[];
|
||||
enableStatusBarInfo?: boolean;
|
||||
@@ -96,6 +103,11 @@ export interface RemotelySavePluginSettings {
|
||||
* @deprecated
|
||||
*/
|
||||
vaultRandomID?: string;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
logToDB?: boolean;
|
||||
}
|
||||
|
||||
export interface RemoteItem {
|
||||
@@ -175,6 +187,7 @@ export interface FileOrFolderMixedState {
|
||||
export const API_VER_STAT_FOLDER = "0.13.27";
|
||||
export const API_VER_REQURL = "0.13.26"; // desktop ver 0.13.26, iOS ver 1.1.1
|
||||
export const API_VER_REQURL_ANDROID = "0.14.6"; // Android ver 1.2.1
|
||||
export const API_VER_ENSURE_REQURL_OK = "1.0.0"; // always bypass CORS here
|
||||
|
||||
export const VALID_REQURL =
|
||||
(!Platform.isAndroidApp && requireApiVersion(API_VER_REQURL)) ||
|
||||
|
||||
+2
-37
@@ -1,10 +1,7 @@
|
||||
import { TAbstractFile, TFolder, TFile, Vault } from "obsidian";
|
||||
|
||||
import type { SyncPlanType } from "./sync";
|
||||
import {
|
||||
readAllSyncPlanRecordTextsByVault,
|
||||
readAllLogRecordTextsByVault,
|
||||
} from "./localdb";
|
||||
import { readAllSyncPlanRecordTextsByVault } from "./localdb";
|
||||
import type { InternalDBs } from "./localdb";
|
||||
import { mkdirpInVault } from "./misc";
|
||||
import {
|
||||
@@ -78,8 +75,7 @@ const turnSyncPlanToTable = (record: string) => {
|
||||
export const exportVaultSyncPlansToFiles = async (
|
||||
db: InternalDBs,
|
||||
vault: Vault,
|
||||
vaultRandomID: string,
|
||||
toFormat: "table" | "json" = "json"
|
||||
vaultRandomID: string
|
||||
) => {
|
||||
log.info("exporting");
|
||||
await mkdirpInVault(DEFAULT_DEBUG_FOLDER, vault);
|
||||
@@ -88,16 +84,9 @@ export const exportVaultSyncPlansToFiles = async (
|
||||
if (records.length === 0) {
|
||||
md = "No sync plans history found";
|
||||
} else {
|
||||
if (toFormat === "json") {
|
||||
md =
|
||||
"Sync plans found:\n\n" +
|
||||
records.map((x) => "```json\n" + x + "\n```\n").join("\n");
|
||||
} else if (toFormat === "table") {
|
||||
md =
|
||||
"Sync plans found:\n\n" + records.map(turnSyncPlanToTable).join("\n\n");
|
||||
} else {
|
||||
const _: never = toFormat;
|
||||
}
|
||||
}
|
||||
const ts = Date.now();
|
||||
const filePath = `${DEFAULT_DEBUG_FOLDER}${DEFAULT_SYNC_PLANS_HISTORY_FILE_PREFIX}${ts}.md`;
|
||||
@@ -106,27 +95,3 @@ export const exportVaultSyncPlansToFiles = async (
|
||||
});
|
||||
log.info("finish exporting");
|
||||
};
|
||||
|
||||
export const exportVaultLoggerOutputToFiles = async (
|
||||
db: InternalDBs,
|
||||
vault: Vault,
|
||||
vaultRandomID: string
|
||||
) => {
|
||||
await mkdirpInVault(DEFAULT_DEBUG_FOLDER, vault);
|
||||
const records = await readAllLogRecordTextsByVault(db, vaultRandomID);
|
||||
let md = "";
|
||||
if (records.length === 0) {
|
||||
md = "No logger history found.";
|
||||
} else {
|
||||
md =
|
||||
"Logger history found:\n\n" +
|
||||
"```text\n" +
|
||||
records.join("\n") +
|
||||
"\n```\n";
|
||||
}
|
||||
const ts = Date.now();
|
||||
const filePath = `${DEFAULT_DEBUG_FOLDER}${DEFAULT_LOG_HISTORY_FILE_PREFIX}${ts}.md`;
|
||||
await vault.create(filePath, md, {
|
||||
mtime: ts,
|
||||
});
|
||||
};
|
||||
|
||||
+10
-19
@@ -28,8 +28,9 @@
|
||||
"protocol_dropbox_connecting": "Connecting to Dropbox...\nPlease DO NOT close this modal.",
|
||||
"protocol_dropbox_connect_succ": "Good! We've connected to Dropbox as user {{username}}!",
|
||||
"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 you rejected the auth?",
|
||||
"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_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?",
|
||||
@@ -37,7 +38,6 @@
|
||||
"command_startsync": "start sync",
|
||||
"command_drynrun": "start sync (dry run only)",
|
||||
"command_exportsyncplans_json": "export sync plans in json format",
|
||||
"command_exportsyncplans_table": "export sync plans in table format",
|
||||
"command_exportlogsindb": "export logs saved in db",
|
||||
|
||||
"statusbar_time_years": "{{time}} years",
|
||||
@@ -163,7 +163,7 @@
|
||||
"settings_s3_prod3": "Configuring CORS",
|
||||
"settings_s3_endpoint": "Endpoint",
|
||||
"settings_s3_region": "Region",
|
||||
"settings_s3_region_desc": "If you are not sure what to enter, you could try the value: us-east-1",
|
||||
"settings_s3_region_desc": "If you are not sure what to enter, you could try the value: us-east-1 .",
|
||||
"settings_s3_accesskeyid": "Access Key ID",
|
||||
"settings_s3_accesskeyid_desc": "Access key ID. Attention: Access key ID and other info are saved locally.",
|
||||
"settings_s3_secretaccesskey": "Secret Access Key",
|
||||
@@ -173,6 +173,8 @@
|
||||
"settings_s3_bypasscorslocally_desc": "The plugin allows skipping server CORS config in new version of Obsidian ( desktop>=0.13.25 or iOS>=1.1.1 or Android>=1.2.1). If you encounter any issues, please disable this setting and config CORS on servers (allowing requests from app://obsidian.md and capacitor://localhost and http://localhost and add ETag into exposed headers).",
|
||||
"settings_s3_parts": "Parts Concurrency",
|
||||
"settings_s3_parts_desc": "Large files are split into small parts to upload in S3. How many parts do you want to upload in parallel at most?",
|
||||
"settings_s3_accuratemtime": "Use Accurate MTime",
|
||||
"settings_s3_accuratemtime_desc": "Read the uploaded accurate last modified time for better sync algorithm. But it causes extra api requests / time / money to the S3 endpoint.",
|
||||
"settings_s3_urlstyle": "S3 URL style",
|
||||
"settings_s3_urlstyle_desc": "Whether to force path-style URLs for S3 objects (e.g., https://s3.amazonaws.com/*/ instead of https://*.s3.amazonaws.com/).",
|
||||
"settings_s3_connect_succ": "Great! The bucket can be accessed.",
|
||||
@@ -260,27 +262,16 @@
|
||||
"settings_outputsettingsconsole_button": "Output",
|
||||
"settings_outputsettingsconsole_notice": "Finished outputing in console.",
|
||||
"settings_syncplans": "Export Sync Plans",
|
||||
"settings_syncplans_desc": "Sync plans are created every time after you trigger sync and before the actual sync. Useful to know what would actually happen in those sync. Click the button to export sync plans. You can choose to export to json or table format inside Markdown, which are equivalent.",
|
||||
"settings_syncplans_button_json": "Export (json)",
|
||||
"settings_syncplans_button_table": "Export (table)",
|
||||
"settings_syncplans_desc": "Sync plans are created every time after you trigger sync and before the actual sync. Useful to know what would actually happen in those sync. Click the button to export sync plans.",
|
||||
"settings_syncplans_button_json": "Export",
|
||||
"settings_syncplans_notice": "Sync plans history exported.",
|
||||
"settings_delsyncplans": "Delete Sync Plans History In DB",
|
||||
"settings_delsyncplans_desc": "Delete sync plans history in DB.",
|
||||
"settings_delsyncplans_button": "Delete Sync Plans History",
|
||||
"settings_delsyncplans_notice": "Sync plans history (in DB) deleted.",
|
||||
"settings_logtodb": "Save Console Logs Into DB",
|
||||
"settings_logtodb_desc": "Enable this to save all console logs into DB, so that we can export and read them later. Especially useful for mobile debugging. Has performance cost and may impact battery. The history is saved for at most 10000 records and 7 days old.",
|
||||
"settings_logtodbexport": "Export Console Logs From DB",
|
||||
"settings_logtodbexport_desc": "Export the saved console logs of this vault from DB into a new file in the folder {{&debugFolder}} .",
|
||||
"settings_logtodbexport_button": "Export",
|
||||
"settings_logtodbexport_notice": "Console logs of this vault from DB are exported!",
|
||||
"settings_logtodbclear": "Delete All Console Logs In DB",
|
||||
"settings_logtodbclear_desc": "Delete all the console logs saved inside DB. This setting applies to all saved logs for all vaults in this device.",
|
||||
"settings_logtodbclear_button": "Delete",
|
||||
"settings_logtodbclear_notice": "All console logs saved in DB are deleted!",
|
||||
"settings_logtohttpserver": "Log To HTTP Server Temporarily",
|
||||
"settings_logtohttpserver_desc": "It's very dangerous and please use the function with greate cautions!!!!! It will temporarily allow sending console loggins to HTTP server.",
|
||||
"settings_logtohttpserver_reset_notice": "Already removed the setting of logging to HTTP server.",
|
||||
"settings_logtohttpserver": "Log To HTTP(S) Server Temporarily",
|
||||
"settings_logtohttpserver_desc": "It's very dangerous and please use the function with greate cautions!!!!! It will temporarily allow sending console loggings to HTTP(S) server.",
|
||||
"settings_logtohttpserver_reset_notice": "Your input doesn't starts with \"http(s)\". Already removed the setting of logging to HTTP(S) server.",
|
||||
"settings_delsyncmap": "Delete Sync Mappings History In DB",
|
||||
"settings_delsyncmap_desc": "Sync mappings history stores the actual LOCAL last modified time of the REMOTE objects. Clearing it may cause unnecessary data exchanges in next-time sync. Click the button to delete sync mappings history in DB.",
|
||||
"settings_delsyncmap_button": "Delete Sync Mappings",
|
||||
|
||||
+10
-19
@@ -28,8 +28,9 @@
|
||||
"protocol_dropbox_connecting": "正在连接 Dropbox……\n请不要关闭此弹窗。",
|
||||
"protocol_dropbox_connect_succ": "好!我们作为用户 {{username}} 连接上了 Dropbox!",
|
||||
"protocol_dropbox_connect_succ_revoke": "您已作为用户 {{username}} 连接上了。如果您想取消连接,请点击此按钮。",
|
||||
"protocol_dropbox_connect_fail": "Dropbox 的回调请求有点异常。您是否拒绝了鉴权?",
|
||||
"protocol_dropbox_connect_fail": "Dropbox 的回调请求有点异常。您是否网络不顺畅?您是否拒绝了鉴权?",
|
||||
"protocol_dropbox_connect_unknown": "不知道如何处理此 callback:{{params}}",
|
||||
"protocol_dropbox_no_modal": "您不是在设置页的弹窗里触发 Dropbox 的。中止操作。",
|
||||
"protocol_onedrive_connecting": "正在连接 OneDrive……\n请不要关闭此弹窗。",
|
||||
"protocol_onedrive_connect_succ_revoke": "您已作为用户 {{username}} 连接上了。如果您想取消连接,请点击此按钮。",
|
||||
"protocol_onedrive_connect_fail": "OneDrive 的回调请求有点异常。您是否拒绝了鉴权?",
|
||||
@@ -37,7 +38,6 @@
|
||||
"command_startsync": "开始同步(start sync)",
|
||||
"command_drynrun": "开始同步(空跑模式)(start sync (dry run only))",
|
||||
"command_exportsyncplans_json": "导出同步计划为 json 格式(export sync plans in json format)",
|
||||
"command_exportsyncplans_table": "导出同步计划为表格格式(export sync plans in table format)",
|
||||
"command_exportlogsindb": "从数据库导出终端日志(export logs saved in db)",
|
||||
|
||||
"statusbar_time_years": "{{time}} 年前",
|
||||
@@ -163,7 +163,7 @@
|
||||
"settings_s3_prod3": "设置 CORS",
|
||||
"settings_s3_endpoint": "服务地址(Endpoint)",
|
||||
"settings_s3_region": "区域(Region)",
|
||||
"settings_s3_region_desc": "如果您不知道这个值填什么,可以尝试填写此默认值:us-east-1",
|
||||
"settings_s3_region_desc": "如果您不知道这个值填什么,可以尝试填写:us-east-1。",
|
||||
"settings_s3_accesskeyid": "Access Key ID",
|
||||
"settings_s3_accesskeyid_desc": "Access key ID。注意:access key ID 和其它信息都会在本地保存。",
|
||||
"settings_s3_secretaccesskey": "Secret Access Key",
|
||||
@@ -173,6 +173,8 @@
|
||||
"settings_s3_bypasscorslocally_desc": "对于 Obsidian 新版本(桌面版>=0.13.25 或 iOS>=1.1.1 或 Android>=1.2.1),本插件可以跳过服务器设置 CORS 的步骤。如果您遇到任意问题,可以关闭此设定,并在服务端设置 CORS(允许来自 app://obsidian.md 和 capacitor://localhost 和 http://localhost 的请求且增加 ETag 到暴露 headers 里)。",
|
||||
"settings_s3_parts": "分块并行度",
|
||||
"settings_s3_parts_desc": "在 S3 里,大文件会被分块上传。您希望同一时间最多有多少个分块被上传?",
|
||||
"settings_s3_accuratemtime": "使用准确的文件修改时间",
|
||||
"settings_s3_accuratemtime_desc": "读取(已上传的)准确的文件修改时间,有助于同步算法更加准确和稳定。但是它也会导致额外的 api 请求、时间、金钱花费。",
|
||||
"settings_s3_urlstyle": "S3 URL style",
|
||||
"settings_s3_urlstyle_desc": "是否对 S3 对象强制使用 path style URL(例如使用 https://s3.amazonaws.com/*/ 而不是 https://*.s3.amazonaws.com/)。",
|
||||
"settings_s3_connect_succ": "很好!可以访问到对应存储桶。",
|
||||
@@ -260,27 +262,16 @@
|
||||
"settings_outputsettingsconsole_button": "输出",
|
||||
"settings_outputsettingsconsole_notice": "已输出到终端",
|
||||
"settings_syncplans": "导出同步计划",
|
||||
"settings_syncplans_desc": "每次您启动同步,并在实际上传下载前,插件会生成同步计划。它可以使您知道每次同步发生了什么。点击按钮可以导出同步计划。并且,您可以选择导出为内嵌在 Markdown 里的 json 格式或表格格式,它们是等价的。",
|
||||
"settings_syncplans_button_json": "导出(json)",
|
||||
"settings_syncplans_button_table": "导出(表格)",
|
||||
"settings_syncplans_desc": "每次您启动同步,并在实际上传下载前,插件会生成同步计划。它可以使您知道每次同步发生了什么。点击按钮可以导出同步计划。",
|
||||
"settings_syncplans_button_json": "导出",
|
||||
"settings_syncplans_notice": "同步计划已导出",
|
||||
"settings_delsyncplans": "删除数据库里的同步计划历史",
|
||||
"settings_delsyncplans_desc": "删除数据库里的同步计划历史。",
|
||||
"settings_delsyncplans_button": "删除同步计划历史",
|
||||
"settings_delsyncplans_notice": "(数据库里的)同步计划已被删除。",
|
||||
"settings_logtodb": "保存终端日志到数据库",
|
||||
"settings_logtodb_desc": "如果开启此设置,所有终端日志都会保存到数据,从而我们可以在之后导出和阅读它们。对于移动设备的调试较为有用。有性能成本,可能会影响电池用量。历史会保存最多 10000 条和 7 天时间。",
|
||||
"settings_logtodbexport": "从数据库导出终端日志",
|
||||
"settings_logtodbexport_desc": "从数据库导出本资料库的已保存的终端日志,输出到文件夹 {{&debugFolder}} 下的一个新文件内。",
|
||||
"settings_logtodbexport_button": "导出",
|
||||
"settings_logtodbexport_notice": "数据库内的本资料库的终端日志已导出!",
|
||||
"settings_logtodbclear": "删除数据库的所有终端日志",
|
||||
"settings_logtodbclear_desc": "删除数据库内的所有已保存的终端日志。本设置会影响本设备下所有资料库的所有已保存日志。",
|
||||
"settings_logtodbclear_button": "删除",
|
||||
"settings_logtodbclear_notice": "数据库内的所有终端日志已删除!",
|
||||
"settings_logtohttpserver": "临时设定终端日志实时转发到 HTTP 服务器。",
|
||||
"settings_logtohttpserver_desc": "非常危险,谨慎行动!!!!!临时设定终端日志实时转发到 HTTP 服务器。",
|
||||
"settings_logtohttpserver_reset_notice": "移除了终端日志转发到 HTTP 服务器的设定。",
|
||||
"settings_logtohttpserver": "临时设定终端日志实时转发到 HTTP(S) 服务器。",
|
||||
"settings_logtohttpserver_desc": "非常危险,谨慎行动!!!!!临时设定终端日志实时转发到 HTTP(S) 服务器。",
|
||||
"settings_logtohttpserver_reset_notice": "您的输入不是“http(s)”开头的。已移除了终端日志转发到 HTTP(S) 服务器的设定。",
|
||||
"settings_delsyncmap": "删除数据库里的同步映射历史",
|
||||
"settings_delsyncmap_desc": "同步映射历史存储了本地真正的最后修改时间和远程文件时间的映射。删除之可能会导致下一次同步时发生不必要的数据交换。点击按钮删除数据库里的同步映射历史。",
|
||||
"settings_delsyncmap_button": "删除同步映射历史",
|
||||
|
||||
+10
-19
@@ -28,8 +28,9 @@
|
||||
"protocol_dropbox_connecting": "正在連線 Dropbox……\n請不要關閉此彈窗。",
|
||||
"protocol_dropbox_connect_succ": "好!我們作為使用者 {{username}} 連線上了 Dropbox!",
|
||||
"protocol_dropbox_connect_succ_revoke": "您已作為使用者 {{username}} 連線上了。如果您想取消連線,請點選此按鈕。",
|
||||
"protocol_dropbox_connect_fail": "Dropbox 的回撥請求有點異常。您是否拒絕了鑑權?",
|
||||
"protocol_dropbox_connect_fail": "Dropbox 的回撥請求有點異常。您是否網路不順暢?您是否拒絕了鑑權?",
|
||||
"protocol_dropbox_connect_unknown": "不知道如何處理此 callback:{{params}}",
|
||||
"protocol_dropbox_no_modal": "您不是在設定頁的彈窗裡觸發 Dropbox 的。中止操作。",
|
||||
"protocol_onedrive_connecting": "正在連線 OneDrive……\n請不要關閉此彈窗。",
|
||||
"protocol_onedrive_connect_succ_revoke": "您已作為使用者 {{username}} 連線上了。如果您想取消連線,請點選此按鈕。",
|
||||
"protocol_onedrive_connect_fail": "OneDrive 的回撥請求有點異常。您是否拒絕了鑑權?",
|
||||
@@ -37,7 +38,6 @@
|
||||
"command_startsync": "開始同步(start sync)",
|
||||
"command_drynrun": "開始同步(空跑模式)(start sync (dry run only))",
|
||||
"command_exportsyncplans_json": "匯出同步計劃為 json 格式(export sync plans in json format)",
|
||||
"command_exportsyncplans_table": "匯出同步計劃為表格格式(export sync plans in table format)",
|
||||
"command_exportlogsindb": "從資料庫匯出終端日誌(export logs saved in db)",
|
||||
|
||||
"statusbar_time_years": "{{time}} 年前",
|
||||
@@ -163,7 +163,7 @@
|
||||
"settings_s3_prod3": "設定 CORS",
|
||||
"settings_s3_endpoint": "服務地址(Endpoint)",
|
||||
"settings_s3_region": "區域(Region)",
|
||||
"settings_s3_region_desc": "如果您不知道這個值填什麼,可以嘗試填寫此預設值:us-east-1",
|
||||
"settings_s3_region_desc": "如果您不知道這個值填什麼,可以嘗試填寫:us-east-1。",
|
||||
"settings_s3_accesskeyid": "Access Key ID",
|
||||
"settings_s3_accesskeyid_desc": "Access key ID。注意:access key ID 和其它資訊都會在本地儲存。",
|
||||
"settings_s3_secretaccesskey": "Secret Access Key",
|
||||
@@ -173,6 +173,8 @@
|
||||
"settings_s3_bypasscorslocally_desc": "對於 Obsidian 新版本(桌面版>=0.13.25 或 iOS>=1.1.1 或 Android>=1.2.1),本外掛可以跳過伺服器設定 CORS 的步驟。如果您遇到任意問題,可以關閉此設定,並在服務端設定 CORS(允許來自 app://obsidian.md 和 capacitor://localhost 和 http://localhost 的請求且增加 ETag 到暴露 headers 裡)。",
|
||||
"settings_s3_parts": "分塊並行度",
|
||||
"settings_s3_parts_desc": "在 S3 裡,大檔案會被分塊上傳。您希望同一時間最多有多少個分塊被上傳?",
|
||||
"settings_s3_accuratemtime": "使用準確的檔案修改時間",
|
||||
"settings_s3_accuratemtime_desc": "讀取(已上傳的)準確的檔案修改時間,有助於同步演算法更加準確和穩定。但是它也會導致額外的 api 請求、時間、金錢花費。",
|
||||
"settings_s3_urlstyle": "S3 URL style",
|
||||
"settings_s3_urlstyle_desc": "是否對 S3 物件強制使用 path style URL(例如使用 https://s3.amazonaws.com/*/ 而不是 https://*.s3.amazonaws.com/)。",
|
||||
"settings_s3_connect_succ": "很好!可以訪問到對應儲存桶。",
|
||||
@@ -260,27 +262,16 @@
|
||||
"settings_outputsettingsconsole_button": "輸出",
|
||||
"settings_outputsettingsconsole_notice": "已輸出到終端",
|
||||
"settings_syncplans": "匯出同步計劃",
|
||||
"settings_syncplans_desc": "每次您啟動同步,並在實際上傳下載前,外掛會生成同步計劃。它可以使您知道每次同步發生了什麼。點選按鈕可以匯出同步計劃。並且,您可以選擇匯出為內嵌在 Markdown 裡的 json 格式或表格格式,它們是等價的。",
|
||||
"settings_syncplans_button_json": "匯出(json)",
|
||||
"settings_syncplans_button_table": "匯出(表格)",
|
||||
"settings_syncplans_desc": "每次您啟動同步,並在實際上傳下載前,外掛會生成同步計劃。它可以使您知道每次同步發生了什麼。點選按鈕可以匯出同步計劃。",
|
||||
"settings_syncplans_button_json": "匯出",
|
||||
"settings_syncplans_notice": "同步計劃已匯出",
|
||||
"settings_delsyncplans": "刪除資料庫裡的同步計劃歷史",
|
||||
"settings_delsyncplans_desc": "刪除資料庫裡的同步計劃歷史。",
|
||||
"settings_delsyncplans_button": "刪除同步計劃歷史",
|
||||
"settings_delsyncplans_notice": "(資料庫裡的)同步計劃已被刪除。",
|
||||
"settings_logtodb": "儲存終端日誌到資料庫",
|
||||
"settings_logtodb_desc": "如果開啟此設定,所有終端日誌都會儲存到資料,從而我們可以在之後匯出和閱讀它們。對於移動裝置的除錯較為有用。有效能成本,可能會影響電池用量。歷史會儲存最多 10000 條和 7 天時間。",
|
||||
"settings_logtodbexport": "從資料庫匯出終端日誌",
|
||||
"settings_logtodbexport_desc": "從資料庫匯出本資料庫的已儲存的終端日誌,輸出到資料夾 {{&debugFolder}} 下的一個新檔案內。",
|
||||
"settings_logtodbexport_button": "匯出",
|
||||
"settings_logtodbexport_notice": "資料庫內的本資料庫的終端日誌已匯出!",
|
||||
"settings_logtodbclear": "刪除資料庫的所有終端日誌",
|
||||
"settings_logtodbclear_desc": "刪除資料庫內的所有已儲存的終端日誌。本設定會影響本裝置下所有資料庫的所有已儲存日誌。",
|
||||
"settings_logtodbclear_button": "刪除",
|
||||
"settings_logtodbclear_notice": "資料庫內的所有終端日誌已刪除!",
|
||||
"settings_logtohttpserver": "臨時設定終端日誌實時轉發到 HTTP 伺服器。",
|
||||
"settings_logtohttpserver_desc": "非常危險,謹慎行動!!!!!臨時設定終端日誌實時轉發到 HTTP 伺服器。",
|
||||
"settings_logtohttpserver_reset_notice": "移除了終端日誌轉發到 HTTP 伺服器的設定。",
|
||||
"settings_logtohttpserver": "臨時設定終端日誌實時轉發到 HTTP(S) 伺服器。",
|
||||
"settings_logtohttpserver_desc": "非常危險,謹慎行動!!!!!臨時設定終端日誌實時轉發到 HTTP(S) 伺服器。",
|
||||
"settings_logtohttpserver_reset_notice": "您的輸入不是“http(s)”開頭的。已移除了終端日誌轉發到 HTTP(S) 伺服器的設定。",
|
||||
"settings_delsyncmap": "刪除資料庫裡的同步對映歷史",
|
||||
"settings_delsyncmap_desc": "同步對映歷史儲存了本地真正的最後修改時間和遠端檔案時間的對映。刪除之可能會導致下一次同步時發生不必要的資料交換。點選按鈕刪除資料庫裡的同步對映歷史。",
|
||||
"settings_delsyncmap_button": "刪除同步對映歷史",
|
||||
|
||||
+5
-88
@@ -608,13 +608,13 @@ export const readAllSyncPlanRecordTextsByVault = async (
|
||||
};
|
||||
|
||||
/**
|
||||
* We remove records that are older than 7 days or 10000 records.
|
||||
* We remove records that are older than 3 days or 100 records.
|
||||
* It's a heavy operation, so we shall not place it in the start up.
|
||||
* @param db
|
||||
*/
|
||||
export const clearExpiredSyncPlanRecords = async (db: InternalDBs) => {
|
||||
const MILLISECONDS_OLD = 1000 * 60 * 60 * 24 * 7; // 7 days
|
||||
const COUNT_TO_MANY = 10000;
|
||||
const MILLISECONDS_OLD = 1000 * 60 * 60 * 24 * 3; // 3 days
|
||||
const COUNT_TO_MANY = 100;
|
||||
|
||||
const currTs = Date.now();
|
||||
const expiredTs = currTs - MILLISECONDS_OLD;
|
||||
@@ -634,7 +634,7 @@ export const clearExpiredSyncPlanRecords = async (db: InternalDBs) => {
|
||||
);
|
||||
|
||||
if (records.length - keysToRemove.size > COUNT_TO_MANY) {
|
||||
// we need to find out records beyond 10000 records
|
||||
// we need to find out records beyond 100 records
|
||||
records = records.filter((x) => !x.expired); // shrink the array
|
||||
records.sort((a, b) => -(a.ts - b.ts)); // descending
|
||||
records.slice(COUNT_TO_MANY).forEach((element) => {
|
||||
@@ -649,92 +649,9 @@ export const clearExpiredSyncPlanRecords = async (db: InternalDBs) => {
|
||||
await Promise.all(ps);
|
||||
};
|
||||
|
||||
export const readAllLogRecordTextsByVault = async (
|
||||
db: InternalDBs,
|
||||
vaultRandomID: string
|
||||
) => {
|
||||
const records = [] as { ts: number; r: string }[];
|
||||
await db.loggerOutputTbl.iterate((value, key, iterationNumber) => {
|
||||
if (key.startsWith(`${vaultRandomID}\t`)) {
|
||||
const item = {
|
||||
ts: parseInt(key.split("\t")[1]),
|
||||
r: value as string,
|
||||
};
|
||||
records.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
// while reading the logs, we want it to be ascending
|
||||
records.sort((a, b) => a.ts - b.ts);
|
||||
|
||||
if (records === undefined) {
|
||||
return [] as string[];
|
||||
} else {
|
||||
return records.map((x) => x.r);
|
||||
}
|
||||
};
|
||||
|
||||
export const insertLoggerOutputByVault = async (
|
||||
db: InternalDBs,
|
||||
vaultRandomID: string,
|
||||
...msg: any[]
|
||||
) => {
|
||||
const ts = Date.now();
|
||||
const tsFmt = unixTimeToStr(ts);
|
||||
const key = `${vaultRandomID}\t${ts}`;
|
||||
|
||||
try {
|
||||
const val = [`[${tsFmt}]`, ...msg.map((x) => toText(x))].join(" ");
|
||||
db.loggerOutputTbl.setItem(key, val);
|
||||
} catch (err) {
|
||||
// give up, and let it pass
|
||||
}
|
||||
};
|
||||
|
||||
export const clearAllLoggerOutputRecords = async (db: InternalDBs) => {
|
||||
await db.loggerOutputTbl.clear();
|
||||
};
|
||||
|
||||
/**
|
||||
* We remove records that are older than 7 days or 10000 records.
|
||||
* It's a heavy operation, so we shall not place it in the start up.
|
||||
* @param db
|
||||
*/
|
||||
export const clearExpiredLoggerOutputRecords = async (db: InternalDBs) => {
|
||||
const MILLISECONDS_OLD = 1000 * 60 * 60 * 24 * 7; // 7 days
|
||||
const COUNT_TO_MANY = 10000;
|
||||
|
||||
const currTs = Date.now();
|
||||
const expiredTs = currTs - MILLISECONDS_OLD;
|
||||
|
||||
let records = (await db.loggerOutputTbl.keys()).map((key) => {
|
||||
const ts = parseInt(key.split("\t")[1]);
|
||||
const expired = ts <= expiredTs;
|
||||
return {
|
||||
ts: ts,
|
||||
key: key,
|
||||
expired: expired,
|
||||
};
|
||||
});
|
||||
|
||||
const keysToRemove = new Set(
|
||||
records.filter((x) => x.expired).map((x) => x.key)
|
||||
);
|
||||
|
||||
if (records.length - keysToRemove.size > COUNT_TO_MANY) {
|
||||
// we need to find out records beyond 10000 records
|
||||
records = records.filter((x) => !x.expired); // shrink the array
|
||||
records.sort((a, b) => -(a.ts - b.ts)); // descending
|
||||
records.slice(COUNT_TO_MANY).forEach((element) => {
|
||||
keysToRemove.add(element.key);
|
||||
});
|
||||
}
|
||||
|
||||
const ps = [] as Promise<void>[];
|
||||
keysToRemove.forEach((element) => {
|
||||
ps.push(db.loggerOutputTbl.removeItem(element));
|
||||
});
|
||||
await Promise.all(ps);
|
||||
log.debug(`successfully clearAllLoggerOutputRecords`);
|
||||
};
|
||||
|
||||
export const upsertLastSuccessSyncByVault = async (
|
||||
|
||||
+34
-55
@@ -10,6 +10,7 @@ import {
|
||||
TFile,
|
||||
TFolder,
|
||||
requestUrl,
|
||||
requireApiVersion,
|
||||
} from "obsidian";
|
||||
import cloneDeep from "lodash/cloneDeep";
|
||||
import { createElement, RotateCcw, RefreshCcw, FileText } from "lucide";
|
||||
@@ -24,6 +25,7 @@ import {
|
||||
COMMAND_CALLBACK_DROPBOX,
|
||||
COMMAND_URI,
|
||||
REMOTELY_SAVE_VERSION_2024PREPARE,
|
||||
API_VER_ENSURE_REQURL_OK,
|
||||
} from "./baseTypes";
|
||||
import { importQrCodeUri } from "./importExport";
|
||||
import {
|
||||
@@ -33,12 +35,11 @@ import {
|
||||
loadFileHistoryTableByVault,
|
||||
prepareDBs,
|
||||
InternalDBs,
|
||||
insertLoggerOutputByVault,
|
||||
clearExpiredLoggerOutputRecords,
|
||||
clearExpiredSyncPlanRecords,
|
||||
upsertLastSuccessSyncByVault,
|
||||
getLastSuccessSyncByVault,
|
||||
upsertPluginVersionByVault,
|
||||
clearAllLoggerOutputRecords,
|
||||
} from "./localdb";
|
||||
import { RemoteClient } from "./remote";
|
||||
import {
|
||||
@@ -69,10 +70,7 @@ import { applyPresetRulesInplace } from "./presetRules";
|
||||
|
||||
import { applyLogWriterInplace, log } from "./moreOnLog";
|
||||
import AggregateError from "aggregate-error";
|
||||
import {
|
||||
exportVaultLoggerOutputToFiles,
|
||||
exportVaultSyncPlansToFiles,
|
||||
} from "./debugMode";
|
||||
import { exportVaultSyncPlansToFiles } from "./debugMode";
|
||||
import { SizesConflictModal } from "./syncSizesConflictNotice";
|
||||
import { compareVersion } from "./misc";
|
||||
|
||||
@@ -579,12 +577,20 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
text: val,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
new Notice(t("protocol_dropbox_no_modal"));
|
||||
return;
|
||||
}
|
||||
|
||||
let authRes = await sendAuthReqDropbox(
|
||||
this.settings.dropbox.clientID,
|
||||
this.oauth2Info.verifier,
|
||||
inputParams.code
|
||||
inputParams.code,
|
||||
async (e: any) => {
|
||||
new Notice(t("protocol_dropbox_connect_fail"));
|
||||
new Notice(`${e}`);
|
||||
throw e;
|
||||
}
|
||||
);
|
||||
|
||||
const self = this;
|
||||
@@ -666,10 +672,16 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
this.settings.onedrive.clientID,
|
||||
this.settings.onedrive.authority,
|
||||
inputParams.code,
|
||||
this.oauth2Info.verifier
|
||||
this.oauth2Info.verifier,
|
||||
async (e: any) => {
|
||||
new Notice(t("protocol_onedrive_connect_fail"));
|
||||
new Notice(`${e}`);
|
||||
return; // throw?
|
||||
}
|
||||
);
|
||||
|
||||
if ((rsp as any).error !== undefined) {
|
||||
new Notice(`${JSON.stringify(rsp)}`);
|
||||
throw Error(`${JSON.stringify(rsp)}`);
|
||||
}
|
||||
|
||||
@@ -773,41 +785,11 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
icon: iconNameLogs,
|
||||
callback: async () => {
|
||||
await exportVaultSyncPlansToFiles(
|
||||
this.db,
|
||||
this.app.vault,
|
||||
this.vaultRandomID,
|
||||
"json"
|
||||
);
|
||||
new Notice(t("settings_syncplans_notice"));
|
||||
},
|
||||
});
|
||||
|
||||
this.addCommand({
|
||||
id: "export-sync-plans-table",
|
||||
name: t("command_exportsyncplans_table"),
|
||||
icon: iconNameLogs,
|
||||
callback: async () => {
|
||||
await exportVaultSyncPlansToFiles(
|
||||
this.db,
|
||||
this.app.vault,
|
||||
this.vaultRandomID,
|
||||
"table"
|
||||
);
|
||||
new Notice(t("settings_syncplans_notice"));
|
||||
},
|
||||
});
|
||||
|
||||
this.addCommand({
|
||||
id: "export-logs-in-db",
|
||||
name: t("command_exportlogsindb"),
|
||||
icon: iconNameLogs,
|
||||
callback: async () => {
|
||||
await exportVaultLoggerOutputToFiles(
|
||||
this.db,
|
||||
this.app.vault,
|
||||
this.vaultRandomID
|
||||
);
|
||||
new Notice(t("settings_logtodbexport_notice"));
|
||||
new Notice(t("settings_syncplans_notice"));
|
||||
},
|
||||
});
|
||||
|
||||
@@ -885,6 +867,10 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
if (this.settings.s3.remotePrefix === undefined) {
|
||||
this.settings.s3.remotePrefix = "";
|
||||
}
|
||||
if (this.settings.s3.useAccurateMTime === undefined) {
|
||||
// it causes money, so disable it by default
|
||||
this.settings.s3.useAccurateMTime = false;
|
||||
}
|
||||
if (this.settings.ignorePaths === undefined) {
|
||||
this.settings.ignorePaths = [];
|
||||
}
|
||||
@@ -897,6 +883,13 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
if (this.settings.deleteToWhere === undefined) {
|
||||
this.settings.deleteToWhere = "system";
|
||||
}
|
||||
this.settings.logToDB = false; // deprecated as of 20240113
|
||||
|
||||
if (requireApiVersion(API_VER_ENSURE_REQURL_OK)) {
|
||||
this.settings.s3.bypassCorsLocally = true; // deprecated as of 20240113
|
||||
}
|
||||
|
||||
await this.saveSettings();
|
||||
}
|
||||
|
||||
async checkIfPresetRulesFollowed() {
|
||||
@@ -1215,9 +1208,6 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
|
||||
redirectLoggingOuputBasedOnSetting() {
|
||||
applyLogWriterInplace((...msg: any[]) => {
|
||||
if (this.settings.logToDB) {
|
||||
insertLoggerOutputByVault(this.db, this.vaultRandomID, ...msg);
|
||||
}
|
||||
if (
|
||||
this.debugServerTemp !== undefined &&
|
||||
this.debugServerTemp.trim().startsWith("http")
|
||||
@@ -1242,24 +1232,13 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
}
|
||||
|
||||
enableAutoClearOutputToDBHistIfSet() {
|
||||
const initClearOutputToDBHistAfterMilliseconds = 1000 * 45;
|
||||
const autoClearOutputToDBHistAfterMilliseconds = 1000 * 60 * 5;
|
||||
const initClearOutputToDBHistAfterMilliseconds = 1000 * 30;
|
||||
|
||||
this.app.workspace.onLayoutReady(() => {
|
||||
// init run
|
||||
window.setTimeout(() => {
|
||||
if (this.settings.logToDB) {
|
||||
clearExpiredLoggerOutputRecords(this.db);
|
||||
}
|
||||
clearAllLoggerOutputRecords(this.db);
|
||||
}, initClearOutputToDBHistAfterMilliseconds);
|
||||
|
||||
// scheduled run
|
||||
const intervalID = window.setInterval(() => {
|
||||
if (this.settings.logToDB) {
|
||||
clearExpiredLoggerOutputRecords(this.db);
|
||||
}
|
||||
}, autoClearOutputToDBHistAfterMilliseconds);
|
||||
this.registerInterval(intervalID);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+69
-38
@@ -41,9 +41,12 @@ export const getDropboxPath = (
|
||||
if (fileOrFolderPath === "/" || fileOrFolderPath === "") {
|
||||
// special
|
||||
key = `/${remoteBaseDir}`;
|
||||
}
|
||||
if (!fileOrFolderPath.startsWith("/")) {
|
||||
// then this is original path in Obsidian
|
||||
} else if (fileOrFolderPath.startsWith("/")) {
|
||||
log.warn(
|
||||
`why the path ${fileOrFolderPath} starts with '/'? but we just go on.`
|
||||
);
|
||||
key = `/${remoteBaseDir}${fileOrFolderPath}`;
|
||||
} else {
|
||||
key = `/${remoteBaseDir}/${fileOrFolderPath}`;
|
||||
}
|
||||
if (key.endsWith("/")) {
|
||||
@@ -87,9 +90,13 @@ const fromDropboxItemToRemoteItem = (
|
||||
etag: `${x.id}\t`,
|
||||
} as RemoteItem;
|
||||
} else if (x[".tag"] === "file") {
|
||||
let mtime = Date.parse(x.client_modified).valueOf();
|
||||
if (mtime === 0) {
|
||||
mtime = Date.parse(x.server_modified).valueOf();
|
||||
}
|
||||
return {
|
||||
key: key,
|
||||
lastModified: Date.parse(x.server_modified).valueOf(),
|
||||
lastModified: mtime,
|
||||
size: x.size,
|
||||
remoteType: "dropbox",
|
||||
etag: `${x.id}\t${x.content_hash}`,
|
||||
@@ -210,8 +217,10 @@ export interface DropboxSuccessAuthRes {
|
||||
export const sendAuthReq = async (
|
||||
appKey: string,
|
||||
verifier: string,
|
||||
authCode: string
|
||||
authCode: string,
|
||||
errorCallBack: any
|
||||
) => {
|
||||
try {
|
||||
const resp1 = await fetch("https://api.dropboxapi.com/oauth2/token", {
|
||||
method: "POST",
|
||||
body: new URLSearchParams({
|
||||
@@ -224,12 +233,19 @@ export const sendAuthReq = async (
|
||||
});
|
||||
const resp2 = (await resp1.json()) as DropboxSuccessAuthRes;
|
||||
return resp2;
|
||||
} catch (e) {
|
||||
log.error(e);
|
||||
if (errorCallBack !== undefined) {
|
||||
await errorCallBack(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const sendRefreshTokenReq = async (
|
||||
appKey: string,
|
||||
refreshToken: string
|
||||
) => {
|
||||
try {
|
||||
log.info("start auto getting refreshed Dropbox access token.");
|
||||
const resp1 = await fetch("https://api.dropboxapi.com/oauth2/token", {
|
||||
method: "POST",
|
||||
@@ -242,6 +258,10 @@ export const sendRefreshTokenReq = async (
|
||||
const resp2 = (await resp1.json()) as DropboxSuccessAuthRes;
|
||||
log.info("finish auto getting refreshed Dropbox access token.");
|
||||
return resp2;
|
||||
} catch (e) {
|
||||
log.error(e);
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
export const setConfigBySuccessfullAuthInplace = async (
|
||||
@@ -457,36 +477,34 @@ export const getDropboxClient = (
|
||||
|
||||
export const getRemoteMeta = async (
|
||||
client: WrappedDropboxClient,
|
||||
fileOrFolderPath: string
|
||||
remotePath: string
|
||||
) => {
|
||||
await client.init();
|
||||
if (fileOrFolderPath === "" || fileOrFolderPath === "/") {
|
||||
// filesGetMetadata doesn't support root folder
|
||||
// we instead try to list files
|
||||
// if no error occurs, we ensemble a fake result.
|
||||
const rsp = await retryReq(() =>
|
||||
client.dropbox.filesListFolder({
|
||||
path: `/${client.remoteBaseDir}`,
|
||||
recursive: false, // don't need to recursive here
|
||||
})
|
||||
);
|
||||
if (rsp.status !== 200) {
|
||||
throw Error(JSON.stringify(rsp));
|
||||
}
|
||||
return {
|
||||
key: fileOrFolderPath,
|
||||
lastModified: undefined,
|
||||
size: 0,
|
||||
remoteType: "dropbox",
|
||||
etag: undefined,
|
||||
} as RemoteItem;
|
||||
}
|
||||
|
||||
const key = getDropboxPath(fileOrFolderPath, client.remoteBaseDir);
|
||||
// if (remotePath === "" || remotePath === "/") {
|
||||
// // filesGetMetadata doesn't support root folder
|
||||
// // we instead try to list files
|
||||
// // if no error occurs, we ensemble a fake result.
|
||||
// const rsp = await retryReq(() =>
|
||||
// client.dropbox.filesListFolder({
|
||||
// path: `/${client.remoteBaseDir}`,
|
||||
// recursive: false, // don't need to recursive here
|
||||
// })
|
||||
// );
|
||||
// if (rsp.status !== 200) {
|
||||
// throw Error(JSON.stringify(rsp));
|
||||
// }
|
||||
// return {
|
||||
// key: remotePath,
|
||||
// lastModified: undefined,
|
||||
// size: 0,
|
||||
// remoteType: "dropbox",
|
||||
// etag: undefined,
|
||||
// } as RemoteItem;
|
||||
// }
|
||||
|
||||
const rsp = await retryReq(() =>
|
||||
client.dropbox.filesGetMetadata({
|
||||
path: key,
|
||||
path: remotePath,
|
||||
})
|
||||
);
|
||||
if (rsp.status !== 200) {
|
||||
@@ -504,7 +522,9 @@ export const uploadToRemote = async (
|
||||
remoteEncryptedKey: string = "",
|
||||
foldersCreatedBefore: Set<string> | undefined = undefined,
|
||||
uploadRaw: boolean = false,
|
||||
rawContent: string | ArrayBuffer = ""
|
||||
rawContent: string | ArrayBuffer = "",
|
||||
rawContentMTime: number = 0,
|
||||
rawContentCTime: number = 0
|
||||
) => {
|
||||
await client.init();
|
||||
|
||||
@@ -520,6 +540,15 @@ export const uploadToRemote = async (
|
||||
);
|
||||
}
|
||||
|
||||
let mtime = 0;
|
||||
let ctime = 0;
|
||||
const s = await vault?.adapter?.stat(fileOrFolderPath);
|
||||
if (s !== undefined && s !== null) {
|
||||
mtime = Math.round(s.mtime / 1000.0) * 1000;
|
||||
ctime = Math.round(s.ctime / 1000.0) * 1000;
|
||||
}
|
||||
const mtimeStr = new Date(mtime).toISOString().replace(/\.\d{3}Z$/, "Z");
|
||||
|
||||
const isFolder = fileOrFolderPath.endsWith("/");
|
||||
|
||||
if (isFolder && isRecursively) {
|
||||
@@ -565,6 +594,7 @@ export const uploadToRemote = async (
|
||||
client.dropbox.filesUpload({
|
||||
path: uploadFile,
|
||||
contents: "",
|
||||
client_modified: mtimeStr,
|
||||
}),
|
||||
fileOrFolderPath
|
||||
);
|
||||
@@ -598,6 +628,7 @@ export const uploadToRemote = async (
|
||||
mode: {
|
||||
".tag": "overwrite",
|
||||
},
|
||||
client_modified: mtimeStr,
|
||||
}),
|
||||
fileOrFolderPath
|
||||
);
|
||||
@@ -659,16 +690,15 @@ export const listAllFromRemote = async (client: WrappedDropboxClient) => {
|
||||
|
||||
const downloadFromRemoteRaw = async (
|
||||
client: WrappedDropboxClient,
|
||||
fileOrFolderPath: string
|
||||
remotePath: string
|
||||
) => {
|
||||
await client.init();
|
||||
const key = getDropboxPath(fileOrFolderPath, client.remoteBaseDir);
|
||||
const rsp = await retryReq(
|
||||
() =>
|
||||
client.dropbox.filesDownload({
|
||||
path: key,
|
||||
path: remotePath,
|
||||
}),
|
||||
fileOrFolderPath
|
||||
`downloadFromRemoteRaw=${remotePath}`
|
||||
);
|
||||
if ((rsp.result as any).fileBlob !== undefined) {
|
||||
// we get a Blob
|
||||
@@ -752,8 +782,8 @@ export const deleteFromRemote = async (
|
||||
fileOrFolderPath
|
||||
);
|
||||
} catch (err) {
|
||||
console.error("some error while deleting");
|
||||
console.error(err);
|
||||
log.error("some error while deleting");
|
||||
log.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -762,7 +792,8 @@ export const checkConnectivity = async (
|
||||
callbackFunc?: any
|
||||
) => {
|
||||
try {
|
||||
const results = await getRemoteMeta(client, "/");
|
||||
await client.init();
|
||||
const results = await getRemoteMeta(client, `/${client.remoteBaseDir}`);
|
||||
if (results === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+91
-17
@@ -2,6 +2,7 @@ import { CryptoProvider, PublicClientApplication } from "@azure/msal-node";
|
||||
import { AuthenticationProvider } from "@microsoft/microsoft-graph-client";
|
||||
import type {
|
||||
DriveItem,
|
||||
FileSystemInfo,
|
||||
UploadSession,
|
||||
User,
|
||||
} from "@microsoft/microsoft-graph-types";
|
||||
@@ -105,7 +106,8 @@ export const sendAuthReq = async (
|
||||
clientID: string,
|
||||
authority: string,
|
||||
authCode: string,
|
||||
verifier: string
|
||||
verifier: string,
|
||||
errorCallBack: any
|
||||
) => {
|
||||
// // original code snippets for references
|
||||
// const authResponse = await pca.acquireTokenByCode({
|
||||
@@ -123,6 +125,7 @@ export const sendAuthReq = async (
|
||||
// instead of using msal
|
||||
// https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
|
||||
// https://docs.microsoft.com/en-us/onedrive/developer/rest-api/getting-started/graph-oauth?view=odsp-graph-online#code-flow
|
||||
try {
|
||||
const rsp1 = await request({
|
||||
url: `${authority}/oauth2/v2.0/token`,
|
||||
method: "POST",
|
||||
@@ -146,6 +149,10 @@ export const sendAuthReq = async (
|
||||
} else {
|
||||
return rsp2 as AccessCodeResponseSuccessfulType;
|
||||
}
|
||||
} catch (e) {
|
||||
log.error(e);
|
||||
await errorCallBack(e);
|
||||
}
|
||||
};
|
||||
|
||||
export const sendRefreshTokenReq = async (
|
||||
@@ -154,6 +161,7 @@ export const sendRefreshTokenReq = async (
|
||||
refreshToken: string
|
||||
) => {
|
||||
// also use Obsidian request to bypass CORS issue.
|
||||
try {
|
||||
const rsp1 = await request({
|
||||
url: `${authority}/oauth2/v2.0/token`,
|
||||
method: "POST",
|
||||
@@ -175,6 +183,10 @@ export const sendRefreshTokenReq = async (
|
||||
} else {
|
||||
return rsp2 as AccessCodeResponseSuccessfulType;
|
||||
}
|
||||
} catch (e) {
|
||||
log.error(e);
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
export const setConfigBySuccessfullAuthInplace = async (
|
||||
@@ -207,10 +219,6 @@ export const setConfigBySuccessfullAuthInplace = async (
|
||||
const getOnedrivePath = (fileOrFolderPath: string, remoteBaseDir: string) => {
|
||||
// https://docs.microsoft.com/en-us/onedrive/developer/rest-api/concepts/special-folders-appfolder?view=odsp-graph-online
|
||||
const prefix = `/drive/special/approot:/${remoteBaseDir}`;
|
||||
if (fileOrFolderPath.startsWith(prefix)) {
|
||||
// already transformed, return as is
|
||||
return fileOrFolderPath;
|
||||
}
|
||||
|
||||
let key = fileOrFolderPath;
|
||||
if (fileOrFolderPath === "/" || fileOrFolderPath === "") {
|
||||
@@ -221,7 +229,12 @@ const getOnedrivePath = (fileOrFolderPath: string, remoteBaseDir: string) => {
|
||||
key = key.slice(0, key.length - 1);
|
||||
}
|
||||
|
||||
if (key.startsWith("/")) {
|
||||
log.warn(`why the path ${key} starts with '/'? but we just go on.`);
|
||||
key = `${prefix}${key}`;
|
||||
} else {
|
||||
key = `${prefix}/${key}`;
|
||||
}
|
||||
return key;
|
||||
};
|
||||
|
||||
@@ -260,14 +273,20 @@ const fromDriveItemToRemoteItem = (
|
||||
// e.g.: /Livefolders/应用/remotely-save/${remoteBaseDir}
|
||||
const SECOND_COMMON_PREFIX_REGEX = /^\/Livefolders\/[^\/]+\/remotely-save\//g;
|
||||
|
||||
// another report, why???
|
||||
// /drive/root:/something/app/remotely-save/${remoteBaseDir}
|
||||
const THIRD_COMMON_PREFIX_REGEX =
|
||||
/^\/drive\/root:\/[^\/]+\/app\/remotely-save\//g;
|
||||
|
||||
// another possibile prefix
|
||||
const THIRD_COMMON_PREFIX_RAW = `/drive/items/`;
|
||||
const FOURTH_COMMON_PREFIX_RAW = `/drive/items/`;
|
||||
|
||||
const fullPathOriginal = `${x.parentReference.path}/${x.name}`;
|
||||
const matchFirstPrefixRes = fullPathOriginal.match(FIRST_COMMON_PREFIX_REGEX);
|
||||
const matchSecondPrefixRes = fullPathOriginal.match(
|
||||
SECOND_COMMON_PREFIX_REGEX
|
||||
);
|
||||
const matchThirdPrefixRes = fullPathOriginal.match(THIRD_COMMON_PREFIX_REGEX);
|
||||
if (
|
||||
matchFirstPrefixRes !== null &&
|
||||
fullPathOriginal.startsWith(`${matchFirstPrefixRes[0]}${remoteBaseDir}`)
|
||||
@@ -280,7 +299,13 @@ const fromDriveItemToRemoteItem = (
|
||||
) {
|
||||
const foundPrefix = `${matchSecondPrefixRes[0]}${remoteBaseDir}`;
|
||||
key = fullPathOriginal.substring(foundPrefix.length + 1);
|
||||
} else if (x.parentReference.path.startsWith(THIRD_COMMON_PREFIX_RAW)) {
|
||||
} else if (
|
||||
matchThirdPrefixRes !== null &&
|
||||
fullPathOriginal.startsWith(`${matchThirdPrefixRes[0]}${remoteBaseDir}`)
|
||||
) {
|
||||
const foundPrefix = `${matchThirdPrefixRes[0]}${remoteBaseDir}`;
|
||||
key = fullPathOriginal.substring(foundPrefix.length + 1);
|
||||
} else if (x.parentReference.path.startsWith(FOURTH_COMMON_PREFIX_RAW)) {
|
||||
// it's something like
|
||||
// /drive/items/<some_id>!<another_id>:/${remoteBaseDir}/<subfolder>
|
||||
// with uri encoded!
|
||||
@@ -638,10 +663,9 @@ export const listAllFromRemote = async (client: WrappedOnedriveClient) => {
|
||||
|
||||
export const getRemoteMeta = async (
|
||||
client: WrappedOnedriveClient,
|
||||
fileOrFolderPath: string
|
||||
remotePath: string
|
||||
) => {
|
||||
await client.init();
|
||||
const remotePath = getOnedrivePath(fileOrFolderPath, client.remoteBaseDir);
|
||||
// log.info(`remotePath=${remotePath}`);
|
||||
const rsp = await client.getJson(
|
||||
`${remotePath}?$select=cTag,eTag,fileSystemInfo,folder,file,name,parentReference,size`
|
||||
@@ -673,6 +697,16 @@ export const uploadToRemote = async (
|
||||
uploadFile = getOnedrivePath(uploadFile, client.remoteBaseDir);
|
||||
log.debug(`uploadFile=${uploadFile}`);
|
||||
|
||||
let mtime = 0;
|
||||
let ctime = 0;
|
||||
const s = await vault?.adapter?.stat(fileOrFolderPath);
|
||||
if (s !== undefined && s !== null) {
|
||||
mtime = s.mtime;
|
||||
ctime = s.ctime;
|
||||
}
|
||||
const ctimeStr = new Date(ctime).toISOString();
|
||||
const mtimeStr = new Date(mtime).toISOString();
|
||||
|
||||
const isFolder = fileOrFolderPath.endsWith("/");
|
||||
|
||||
if (isFolder && isRecursively) {
|
||||
@@ -689,10 +723,21 @@ export const uploadToRemote = async (
|
||||
} else {
|
||||
// https://stackoverflow.com/questions/56479865/creating-nested-folders-in-one-go-onedrive-api
|
||||
// use PATCH to create folder recursively!!!
|
||||
await client.patchJson(uploadFile, {
|
||||
let k: any = {
|
||||
folder: {},
|
||||
"@microsoft.graph.conflictBehavior": "replace",
|
||||
});
|
||||
};
|
||||
if (mtime !== 0 && ctime !== 0) {
|
||||
k = {
|
||||
folder: {},
|
||||
"@microsoft.graph.conflictBehavior": "replace",
|
||||
fileSystemInfo: {
|
||||
lastModifiedDateTime: mtimeStr,
|
||||
createdDateTime: ctimeStr,
|
||||
} as FileSystemInfo,
|
||||
};
|
||||
}
|
||||
await client.patchJson(uploadFile, k);
|
||||
}
|
||||
const res = await getRemoteMeta(client, uploadFile);
|
||||
return res;
|
||||
@@ -716,6 +761,14 @@ export const uploadToRemote = async (
|
||||
})}`,
|
||||
arrBufRandom
|
||||
);
|
||||
if (mtime !== 0 && ctime !== 0) {
|
||||
await client.patchJson(`${uploadFile}`, {
|
||||
fileSystemInfo: {
|
||||
lastModifiedDateTime: mtimeStr,
|
||||
createdDateTime: ctimeStr,
|
||||
} as FileSystemInfo,
|
||||
});
|
||||
}
|
||||
// log.info(uploadResult)
|
||||
const res = await getRemoteMeta(client, uploadFile);
|
||||
return res;
|
||||
@@ -753,19 +806,41 @@ export const uploadToRemote = async (
|
||||
})}`,
|
||||
remoteContent
|
||||
);
|
||||
if (mtime !== 0 && ctime !== 0) {
|
||||
await client.patchJson(`${uploadFile}`, {
|
||||
fileSystemInfo: {
|
||||
lastModifiedDateTime: mtimeStr,
|
||||
createdDateTime: ctimeStr,
|
||||
} as FileSystemInfo,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// upload large files!
|
||||
// ref: https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_createuploadsession?view=odsp-graph-online
|
||||
|
||||
// 1. create uploadSession
|
||||
// uploadFile already starts with /drive/special/approot:/${remoteBaseDir}
|
||||
const s: UploadSession = await client.postJson(
|
||||
`${uploadFile}:/createUploadSession`,
|
||||
{
|
||||
let k: any = {
|
||||
item: {
|
||||
"@microsoft.graph.conflictBehavior": "replace",
|
||||
},
|
||||
};
|
||||
if (mtime !== 0 && ctime !== 0) {
|
||||
k = {
|
||||
item: {
|
||||
"@microsoft.graph.conflictBehavior": "replace",
|
||||
|
||||
// this is only possible using uploadSession
|
||||
fileSystemInfo: {
|
||||
lastModifiedDateTime: mtimeStr,
|
||||
createdDateTime: ctimeStr,
|
||||
} as FileSystemInfo,
|
||||
},
|
||||
};
|
||||
}
|
||||
const s: UploadSession = await client.postJson(
|
||||
`${uploadFile}:/createUploadSession`,
|
||||
k
|
||||
);
|
||||
const uploadUrl = s.uploadUrl;
|
||||
log.debug("uploadSession = ");
|
||||
@@ -796,12 +871,11 @@ export const uploadToRemote = async (
|
||||
|
||||
const downloadFromRemoteRaw = async (
|
||||
client: WrappedOnedriveClient,
|
||||
fileOrFolderPath: string
|
||||
remotePath: string
|
||||
): Promise<ArrayBuffer> => {
|
||||
await client.init();
|
||||
const key = getOnedrivePath(fileOrFolderPath, client.remoteBaseDir);
|
||||
const rsp = await client.getJson(
|
||||
`${key}?$select=@microsoft.graph.downloadUrl`
|
||||
`${remotePath}?$select=@microsoft.graph.downloadUrl`
|
||||
);
|
||||
const downloadUrl: string = rsp["@microsoft.graph.downloadUrl"];
|
||||
if (VALID_REQURL) {
|
||||
|
||||
+113
-10
@@ -42,6 +42,7 @@ import {
|
||||
export { S3Client } from "@aws-sdk/client-s3";
|
||||
|
||||
import { log } from "./moreOnLog";
|
||||
import PQueue from "p-queue";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// special handler using Obsidian requestUrl
|
||||
@@ -155,7 +156,7 @@ class ObsHttpHandler extends FetchHttpHandler {
|
||||
// other stuffs
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
export const DEFAULT_S3_CONFIG = {
|
||||
export const DEFAULT_S3_CONFIG: S3Config = {
|
||||
s3Endpoint: "",
|
||||
s3Region: "",
|
||||
s3AccessKeyID: "",
|
||||
@@ -165,6 +166,7 @@ export const DEFAULT_S3_CONFIG = {
|
||||
partsConcurrency: 20,
|
||||
forcePathStyle: false,
|
||||
remotePrefix: "",
|
||||
useAccurateMTime: false, // it causes money, disable by default
|
||||
};
|
||||
|
||||
export type S3ObjectType = _Object;
|
||||
@@ -218,24 +220,47 @@ const getLocalNoPrefixPath = (
|
||||
return fileOrFolderPathWithRemotePrefix.slice(`${remotePrefix}`.length);
|
||||
};
|
||||
|
||||
const fromS3ObjectToRemoteItem = (x: S3ObjectType, remotePrefix: string) => {
|
||||
return {
|
||||
const fromS3ObjectToRemoteItem = (
|
||||
x: S3ObjectType,
|
||||
remotePrefix: string,
|
||||
mtimeRecords: Record<string, number>,
|
||||
ctimeRecords: Record<string, number>
|
||||
) => {
|
||||
let mtime = x.LastModified.valueOf();
|
||||
if (x.Key in mtimeRecords) {
|
||||
const m2 = mtimeRecords[x.Key];
|
||||
if (m2 !== 0) {
|
||||
mtime = m2;
|
||||
}
|
||||
}
|
||||
const r: RemoteItem = {
|
||||
key: getLocalNoPrefixPath(x.Key, remotePrefix),
|
||||
lastModified: x.LastModified.valueOf(),
|
||||
lastModified: mtime,
|
||||
size: x.Size,
|
||||
remoteType: "s3",
|
||||
etag: x.ETag,
|
||||
} as RemoteItem;
|
||||
};
|
||||
return r;
|
||||
};
|
||||
|
||||
const fromS3HeadObjectToRemoteItem = (
|
||||
fileOrFolderPathWithRemotePrefix: string,
|
||||
x: HeadObjectCommandOutput,
|
||||
remotePrefix: string
|
||||
remotePrefix: string,
|
||||
useAccurateMTime: boolean
|
||||
) => {
|
||||
let mtime = x.LastModified.valueOf();
|
||||
if (useAccurateMTime && x.Metadata !== undefined) {
|
||||
const m2 = Math.round(
|
||||
parseFloat(x.Metadata.mtime || x.Metadata.MTime || "0")
|
||||
);
|
||||
if (m2 !== 0) {
|
||||
mtime = m2;
|
||||
}
|
||||
}
|
||||
return {
|
||||
key: getLocalNoPrefixPath(fileOrFolderPathWithRemotePrefix, remotePrefix),
|
||||
lastModified: x.LastModified.valueOf(),
|
||||
lastModified: mtime,
|
||||
size: x.ContentLength,
|
||||
remoteType: "s3",
|
||||
etag: x.ETag,
|
||||
@@ -307,7 +332,8 @@ export const getRemoteMeta = async (
|
||||
return fromS3HeadObjectToRemoteItem(
|
||||
fileOrFolderPathWithRemotePrefix,
|
||||
res,
|
||||
s3Config.remotePrefix
|
||||
s3Config.remotePrefix,
|
||||
s3Config.useAccurateMTime
|
||||
);
|
||||
};
|
||||
|
||||
@@ -320,7 +346,9 @@ export const uploadToRemote = async (
|
||||
password: string = "",
|
||||
remoteEncryptedKey: string = "",
|
||||
uploadRaw: boolean = false,
|
||||
rawContent: string | ArrayBuffer = ""
|
||||
rawContent: string | ArrayBuffer = "",
|
||||
rawContentMTime: number = 0,
|
||||
rawContentCTime: number = 0
|
||||
) => {
|
||||
let uploadFile = fileOrFolderPath;
|
||||
if (password !== "") {
|
||||
@@ -336,6 +364,13 @@ export const uploadToRemote = async (
|
||||
throw Error(`you specify uploadRaw, but you also provide a folder key!`);
|
||||
}
|
||||
// folder
|
||||
let mtime = 0;
|
||||
let ctime = 0;
|
||||
const s = await vault?.adapter?.stat(fileOrFolderPath);
|
||||
if (s !== undefined && s !== null) {
|
||||
mtime = s.mtime;
|
||||
ctime = s.ctime;
|
||||
}
|
||||
const contentType = DEFAULT_CONTENT_TYPE;
|
||||
await s3Client.send(
|
||||
new PutObjectCommand({
|
||||
@@ -343,6 +378,10 @@ export const uploadToRemote = async (
|
||||
Key: uploadFile,
|
||||
Body: "",
|
||||
ContentType: contentType,
|
||||
Metadata: {
|
||||
MTime: `${mtime}`,
|
||||
CTime: `${ctime}`,
|
||||
},
|
||||
})
|
||||
);
|
||||
return await getRemoteMeta(s3Client, s3Config, uploadFile);
|
||||
@@ -357,14 +396,23 @@ export const uploadToRemote = async (
|
||||
) || DEFAULT_CONTENT_TYPE;
|
||||
}
|
||||
let localContent = undefined;
|
||||
let mtime = 0;
|
||||
let ctime = 0;
|
||||
if (uploadRaw) {
|
||||
if (typeof rawContent === "string") {
|
||||
localContent = new TextEncoder().encode(rawContent).buffer;
|
||||
} else {
|
||||
localContent = rawContent;
|
||||
}
|
||||
mtime = rawContentMTime;
|
||||
ctime = rawContentCTime;
|
||||
} else {
|
||||
localContent = await vault.adapter.readBinary(fileOrFolderPath);
|
||||
const s = await vault?.adapter?.stat(fileOrFolderPath);
|
||||
if (s !== undefined && s !== null) {
|
||||
mtime = s.mtime;
|
||||
ctime = s.ctime;
|
||||
}
|
||||
}
|
||||
let remoteContent = localContent;
|
||||
if (password !== "") {
|
||||
@@ -373,6 +421,7 @@ export const uploadToRemote = async (
|
||||
|
||||
const bytesIn5MB = 5242880;
|
||||
const body = new Uint8Array(remoteContent);
|
||||
|
||||
const upload = new Upload({
|
||||
client: s3Client,
|
||||
queueSize: s3Config.partsConcurrency, // concurrency
|
||||
@@ -383,6 +432,10 @@ export const uploadToRemote = async (
|
||||
Key: uploadFile,
|
||||
Body: body,
|
||||
ContentType: contentType,
|
||||
Metadata: {
|
||||
MTime: `${mtime}`,
|
||||
CTime: `${ctime}`,
|
||||
},
|
||||
},
|
||||
});
|
||||
upload.on("httpUploadProgress", (progress) => {
|
||||
@@ -407,6 +460,17 @@ const listFromRemoteRaw = async (
|
||||
}
|
||||
|
||||
const contents = [] as _Object[];
|
||||
const mtimeRecords: Record<string, number> = {};
|
||||
const ctimeRecords: Record<string, number> = {};
|
||||
const queueHead = new PQueue({
|
||||
concurrency: s3Config.partsConcurrency,
|
||||
autoStart: true,
|
||||
});
|
||||
queueHead.on("error", (error) => {
|
||||
queueHead.pause();
|
||||
queueHead.clear();
|
||||
throw error;
|
||||
});
|
||||
|
||||
let isTruncated = true;
|
||||
do {
|
||||
@@ -420,6 +484,37 @@ const listFromRemoteRaw = async (
|
||||
}
|
||||
contents.push(...rsp.Contents);
|
||||
|
||||
if (s3Config.useAccurateMTime) {
|
||||
// head requests of all objects, love it
|
||||
for (const content of rsp.Contents) {
|
||||
queueHead.add(async () => {
|
||||
const rspHead = await s3Client.send(
|
||||
new HeadObjectCommand({
|
||||
Bucket: s3Config.s3BucketName,
|
||||
Key: content.Key,
|
||||
})
|
||||
);
|
||||
if (rspHead.$metadata.httpStatusCode !== 200) {
|
||||
throw Error("some thing bad while heading single object!");
|
||||
}
|
||||
if (rspHead.Metadata === undefined) {
|
||||
// pass
|
||||
} else {
|
||||
mtimeRecords[content.Key] = Math.round(
|
||||
parseFloat(
|
||||
rspHead.Metadata.mtime || rspHead.Metadata.MTime || "0"
|
||||
)
|
||||
);
|
||||
ctimeRecords[content.Key] = Math.round(
|
||||
parseFloat(
|
||||
rspHead.Metadata.ctime || rspHead.Metadata.CTime || "0"
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
isTruncated = rsp.IsTruncated;
|
||||
confCmd.ContinuationToken = rsp.NextContinuationToken;
|
||||
if (
|
||||
@@ -431,12 +526,20 @@ const listFromRemoteRaw = async (
|
||||
}
|
||||
} while (isTruncated);
|
||||
|
||||
// wait for any head requests
|
||||
await queueHead.onIdle();
|
||||
|
||||
// ensemble fake rsp
|
||||
// in the end, we need to transform the response list
|
||||
// back to the local contents-alike list
|
||||
return {
|
||||
Contents: contents.map((x) =>
|
||||
fromS3ObjectToRemoteItem(x, s3Config.remotePrefix)
|
||||
fromS3ObjectToRemoteItem(
|
||||
x,
|
||||
s3Config.remotePrefix,
|
||||
mtimeRecords,
|
||||
ctimeRecords
|
||||
)
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
+30
-21
@@ -56,9 +56,9 @@ if (VALID_REQURL) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log(`requesting url=${options.url}`);
|
||||
// console.log(`contentType=${contentType}`);
|
||||
// console.log(`rspHeaders=${JSON.stringify(rspHeaders)}`)
|
||||
// log.info(`requesting url=${options.url}`);
|
||||
// log.info(`contentType=${contentType}`);
|
||||
// log.info(`rspHeaders=${JSON.stringify(rspHeaders)}`)
|
||||
|
||||
// let r2: Response = undefined;
|
||||
// if (contentType.includes("xml")) {
|
||||
@@ -71,9 +71,9 @@ if (VALID_REQURL) {
|
||||
// contentType.includes("json") ||
|
||||
// contentType.includes("javascript")
|
||||
// ) {
|
||||
// console.log('inside json branch');
|
||||
// log.info('inside json branch');
|
||||
// // const j = r.json;
|
||||
// // console.log(j);
|
||||
// // log.info(j);
|
||||
// r2 = new Response(
|
||||
// r.text, // yea, here is the text because Response constructor expects a text
|
||||
// {
|
||||
@@ -148,8 +148,12 @@ const getWebdavPath = (fileOrFolderPath: string, remoteBaseDir: string) => {
|
||||
if (fileOrFolderPath === "/" || fileOrFolderPath === "") {
|
||||
// special
|
||||
key = `/${remoteBaseDir}/`;
|
||||
}
|
||||
if (!fileOrFolderPath.startsWith("/")) {
|
||||
} else if (fileOrFolderPath.startsWith("/")) {
|
||||
log.warn(
|
||||
`why the path ${fileOrFolderPath} starts with '/'? but we just go on.`
|
||||
);
|
||||
key = `/${remoteBaseDir}${fileOrFolderPath}`;
|
||||
} else {
|
||||
key = `/${remoteBaseDir}/${fileOrFolderPath}`;
|
||||
}
|
||||
return key;
|
||||
@@ -314,16 +318,22 @@ export const getWebdavClient = (
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param client
|
||||
* @param remotePath It should be prefix-ed already
|
||||
* @returns
|
||||
*/
|
||||
export const getRemoteMeta = async (
|
||||
client: WrappedWebdavClient,
|
||||
fileOrFolderPath: string
|
||||
remotePath: string
|
||||
) => {
|
||||
await client.init();
|
||||
const remotePath = getWebdavPath(fileOrFolderPath, client.remoteBaseDir);
|
||||
// log.info(`remotePath = ${remotePath}`);
|
||||
log.debug(`getRemoteMeta remotePath = ${remotePath}`);
|
||||
const res = (await client.client.stat(remotePath, {
|
||||
details: false,
|
||||
})) as FileStat;
|
||||
log.debug(`getRemoteMeta res=${JSON.stringify(res)}`);
|
||||
return fromWebdavItemToRemoteItem(res, client.remoteBaseDir);
|
||||
};
|
||||
|
||||
@@ -470,12 +480,11 @@ export const listAllFromRemote = async (client: WrappedWebdavClient) => {
|
||||
|
||||
const downloadFromRemoteRaw = async (
|
||||
client: WrappedWebdavClient,
|
||||
fileOrFolderPath: string
|
||||
remotePath: string
|
||||
) => {
|
||||
await client.init();
|
||||
const p = getWebdavPath(fileOrFolderPath, client.remoteBaseDir);
|
||||
// console.log(`getWebdavPath=${p}`);
|
||||
const buff = (await client.client.getFileContents(p)) as BufferLike;
|
||||
// log.info(`getWebdavPath=${remotePath}`);
|
||||
const buff = (await client.client.getFileContents(remotePath)) as BufferLike;
|
||||
if (buff instanceof ArrayBuffer) {
|
||||
return buff;
|
||||
} else if (buff instanceof Buffer) {
|
||||
@@ -514,7 +523,7 @@ export const downloadFromRemote = async (
|
||||
downloadFile = remoteEncryptedKey;
|
||||
}
|
||||
downloadFile = getWebdavPath(downloadFile, client.remoteBaseDir);
|
||||
// console.log(`downloadFile=${downloadFile}`);
|
||||
// log.info(`downloadFile=${downloadFile}`);
|
||||
const remoteContent = await downloadFromRemoteRaw(client, downloadFile);
|
||||
let localContent = remoteContent;
|
||||
if (password !== "") {
|
||||
@@ -549,8 +558,8 @@ export const deleteFromRemote = async (
|
||||
await client.client.deleteFile(remoteFileName);
|
||||
// log.info(`delete ${remoteFileName} succeeded`);
|
||||
} catch (err) {
|
||||
console.error("some error while deleting");
|
||||
log.info(err);
|
||||
log.error("some error while deleting");
|
||||
log.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -565,7 +574,7 @@ export const checkConnectivity = async (
|
||||
)
|
||||
) {
|
||||
const err = "Error: the url should start with http(s):// but it does not!";
|
||||
log.debug(err);
|
||||
log.error(err);
|
||||
if (callbackFunc !== undefined) {
|
||||
callbackFunc(err);
|
||||
}
|
||||
@@ -573,10 +582,10 @@ export const checkConnectivity = async (
|
||||
}
|
||||
try {
|
||||
await client.init();
|
||||
const results = await getRemoteMeta(client, "/");
|
||||
const results = await getRemoteMeta(client, `/${client.remoteBaseDir}`);
|
||||
if (results === undefined) {
|
||||
const err = "results is undefined";
|
||||
log.debug(err);
|
||||
log.error(err);
|
||||
if (callbackFunc !== undefined) {
|
||||
callbackFunc(err);
|
||||
}
|
||||
@@ -584,7 +593,7 @@ export const checkConnectivity = async (
|
||||
}
|
||||
return true;
|
||||
} catch (err) {
|
||||
log.debug(err);
|
||||
log.error(err);
|
||||
if (callbackFunc !== undefined) {
|
||||
callbackFunc(err);
|
||||
}
|
||||
|
||||
+37
-83
@@ -11,6 +11,7 @@ import {
|
||||
import type { TextComponent } from "obsidian";
|
||||
import { createElement, Eye, EyeOff } from "lucide";
|
||||
import {
|
||||
API_VER_ENSURE_REQURL_OK,
|
||||
API_VER_REQURL,
|
||||
DEFAULT_DEBUG_FOLDER,
|
||||
SUPPORTED_SERVICES_TYPE,
|
||||
@@ -19,18 +20,12 @@ import {
|
||||
WebdavAuthType,
|
||||
WebdavDepthType,
|
||||
} from "./baseTypes";
|
||||
import {
|
||||
exportVaultSyncPlansToFiles,
|
||||
exportVaultLoggerOutputToFiles,
|
||||
} from "./debugMode";
|
||||
import { exportVaultSyncPlansToFiles } from "./debugMode";
|
||||
import { exportQrCodeUri } from "./importExport";
|
||||
import {
|
||||
clearAllSyncMetaMapping,
|
||||
clearAllSyncPlanRecords,
|
||||
destroyDBs,
|
||||
clearAllLoggerOutputRecords,
|
||||
insertLoggerOutputByVault,
|
||||
clearExpiredLoggerOutputRecords,
|
||||
upsertLastSuccessSyncByVault,
|
||||
} from "./localdb";
|
||||
import type RemotelySavePlugin from "./main"; // unavoidable
|
||||
@@ -411,7 +406,12 @@ class DropboxAuthModal extends Modal {
|
||||
const authRes = await sendAuthReqDropbox(
|
||||
this.plugin.settings.dropbox.clientID,
|
||||
verifier,
|
||||
authCode
|
||||
authCode,
|
||||
async (e: any) => {
|
||||
new Notice(t("protocol_dropbox_connect_fail"));
|
||||
new Notice(`${e}`);
|
||||
throw e;
|
||||
}
|
||||
);
|
||||
const self = this;
|
||||
setConfigBySuccessfullAuthInplace(
|
||||
@@ -451,7 +451,7 @@ class DropboxAuthModal extends Modal {
|
||||
);
|
||||
this.close();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
log.error(err);
|
||||
new Notice(t("modal_dropboxauth_maualinput_conn_fail"));
|
||||
}
|
||||
});
|
||||
@@ -587,7 +587,7 @@ export class OnedriveRevokeAuthModal extends Modal {
|
||||
new Notice(t("modal_onedriverevokeauth_clean_notice"));
|
||||
this.close();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
log.error(err);
|
||||
new Notice(t("modal_onedriverevokeauth_clean_fail"));
|
||||
}
|
||||
});
|
||||
@@ -963,7 +963,7 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
});
|
||||
});
|
||||
|
||||
if (VALID_REQURL) {
|
||||
if (VALID_REQURL && !requireApiVersion(API_VER_ENSURE_REQURL_OK)) {
|
||||
new Setting(s3Div)
|
||||
.setName(t("settings_s3_bypasscorslocally"))
|
||||
.setDesc(t("settings_s3_bypasscorslocally_desc"))
|
||||
@@ -1010,6 +1010,28 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(s3Div)
|
||||
.setName(t("settings_s3_accuratemtime"))
|
||||
.setDesc(t("settings_s3_accuratemtime_desc"))
|
||||
.addDropdown((dropdown) => {
|
||||
dropdown
|
||||
.addOption("disable", t("disable"))
|
||||
.addOption("enable", t("enable"));
|
||||
|
||||
dropdown
|
||||
.setValue(
|
||||
`${this.plugin.settings.s3.useAccurateMTime ? "enable" : "disable"}`
|
||||
)
|
||||
.onChange(async (val) => {
|
||||
if (val === "enable") {
|
||||
this.plugin.settings.s3.useAccurateMTime = true;
|
||||
} else {
|
||||
this.plugin.settings.s3.useAccurateMTime = false;
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
|
||||
let newS3RemotePrefix = this.plugin.settings.s3.remotePrefix || "";
|
||||
new Setting(s3Div)
|
||||
.setName(t("settings_remoteprefix"))
|
||||
@@ -1130,7 +1152,7 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
);
|
||||
new Notice(t("settings_dropbox_revoke_notice"));
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
log.error(err);
|
||||
new Notice(t("settings_dropbox_revoke_noticeerr"));
|
||||
}
|
||||
});
|
||||
@@ -2052,24 +2074,12 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
await exportVaultSyncPlansToFiles(
|
||||
this.plugin.db,
|
||||
this.app.vault,
|
||||
this.plugin.vaultRandomID,
|
||||
"json"
|
||||
);
|
||||
new Notice(t("settings_syncplans_notice"));
|
||||
});
|
||||
})
|
||||
.addButton(async (button) => {
|
||||
button.setButtonText(t("settings_syncplans_button_table"));
|
||||
button.onClick(async () => {
|
||||
await exportVaultSyncPlansToFiles(
|
||||
this.plugin.db,
|
||||
this.app.vault,
|
||||
this.plugin.vaultRandomID,
|
||||
"table"
|
||||
this.plugin.vaultRandomID
|
||||
);
|
||||
new Notice(t("settings_syncplans_notice"));
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(debugDiv)
|
||||
.setName(t("settings_delsyncplans"))
|
||||
.setDesc(t("settings_delsyncplans_desc"))
|
||||
@@ -2081,63 +2091,6 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(debugDiv)
|
||||
.setName(t("settings_logtodb"))
|
||||
.setDesc(t("settings_logtodb_desc"))
|
||||
.addDropdown(async (dropdown) => {
|
||||
dropdown.addOption("enable", t("enable"));
|
||||
dropdown.addOption("disable", t("disable"));
|
||||
dropdown
|
||||
.setValue(this.plugin.settings.logToDB ? "enable" : "disable")
|
||||
.onChange(async (val: string) => {
|
||||
const logToDB = val === "enable";
|
||||
// if (logToDB) {
|
||||
// applyLogWriterInplace((...msg: any[]) => {
|
||||
// insertLoggerOutputByVault(
|
||||
// this.plugin.db,
|
||||
// this.plugin.vaultRandomID,
|
||||
// ...msg
|
||||
// );
|
||||
// });
|
||||
// } else {
|
||||
// restoreLogWritterInplace();
|
||||
// }
|
||||
clearExpiredLoggerOutputRecords(this.plugin.db);
|
||||
this.plugin.settings.logToDB = logToDB;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(debugDiv)
|
||||
.setName(t("settings_logtodbexport"))
|
||||
.setDesc(
|
||||
t("settings_logtodbexport_desc", {
|
||||
debugFolder: DEFAULT_DEBUG_FOLDER,
|
||||
})
|
||||
)
|
||||
.addButton(async (button) => {
|
||||
button.setButtonText(t("settings_logtodbexport_button"));
|
||||
button.onClick(async () => {
|
||||
await exportVaultLoggerOutputToFiles(
|
||||
this.plugin.db,
|
||||
this.app.vault,
|
||||
this.plugin.vaultRandomID
|
||||
);
|
||||
new Notice(t("settings_logtodbexport_notice"));
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(debugDiv)
|
||||
.setName(t("settings_logtodbclear"))
|
||||
.setDesc(t("settings_logtodbclear_desc"))
|
||||
.addButton(async (button) => {
|
||||
button.setButtonText(t("settings_logtodbclear_button"));
|
||||
button.onClick(async () => {
|
||||
await clearAllLoggerOutputRecords(this.plugin.db);
|
||||
new Notice(t("settings_logtodbclear_notice"));
|
||||
});
|
||||
});
|
||||
|
||||
let logToHttpServer = this.plugin.debugServerTemp || "";
|
||||
new Setting(debugDiv)
|
||||
.setName(t("settings_logtohttpserver"))
|
||||
@@ -2215,6 +2168,7 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
button.onClick(async () => {
|
||||
await destroyDBs();
|
||||
new Notice(t("settings_resetcache_notice"));
|
||||
this.plugin.unload();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user