back to the party
This commit is contained in:
parent
9fba9241dc
commit
f3f26f7c0b
@ -191,3 +191,6 @@ export type SyncTriggerSourceType =
|
||||
| "dry"
|
||||
| "autoOnceInit"
|
||||
| "auto_sync_on_save";
|
||||
|
||||
export const REMOTELY_SAVE_VERSION_2022 = "0.3.25";
|
||||
export const REMOTELY_SAVE_VERSION_2024PREPARE = "0.3.32";
|
||||
|
||||
@ -295,5 +295,7 @@
|
||||
"syncalgov2_title": "Remotely Save has a better sync algorithm",
|
||||
"syncalgov2_texts": "Welcome to use Remotely Save!\nFrom version 0.3.0, a new algorithm has been developed, but it needs uploading extra meta data files _remotely-save-metadata-on-remote.{json,bin} to YOUR configured cloud destinations, besides your notes.\nSo that, for example, the second device can know that what files/folders have been deleted on the first device by reading those files.\nIf you agree, plase click the button \"Agree\", and enjoy the plugin! AND PLEASE REMEMBER TO BACKUP YOUR VAULT FIRSTLY!\nIf you do not agree, you should stop using the current and later versions of Remotely Save. You could consider manually install the old version 0.2.14 which uses old algorithm and does not upload any extra meta data files. By clicking the \"Do Not Agree\" button, the plugin will unload itself, and you need to manually disable it in Obsidian settings.",
|
||||
"syncalgov2_button_agree": "Agree",
|
||||
"syncalgov2_button_disagree": "Do Not Agree"
|
||||
"syncalgov2_button_disagree": "Do Not Agree",
|
||||
|
||||
"official_notice_2024_first_party": "Plugin Remotely-Save is back to the party and get a HUGE update!🎉🎉🎉 Try it yourself or see the release note on https://github.com/remotely-save/remotely-save/releases."
|
||||
}
|
||||
|
||||
@ -295,5 +295,7 @@
|
||||
"syncalgov2_title": "Remotely Save 的同步算法得到优化",
|
||||
"syncalgov2_texts": "欢迎使用 Remotely Save!\n从版本 0.3.0 开始,它带来了新的同步算法,但是,除了您的笔记之外,它还需要上传额外的带有元信息的文件 _remotely-save-metadata-on-remote.{json,bin} 到您的云服务目的地上。\n从而,比如说,通过读取这些信息,另一台设备可以知道什么文件或文件夹在第一台设备上被删除了。\n如果您同意此策略,请点击按钮 \"同意\",然后开始享用此插件!且特别要注意:使用插件之前,请首先备份好您的库(Vault)!\n如果您不同意此策略,您应该停止使用此版本和之后版本的 Remotely Save。您可以考虑手动安装旧版 0.2.14,它使用旧的同步算法,并不上传额外元信息文件。点击 \"不同意\" 之后,插件会自动停止运行(unload),然后您需要 Obsidian 设置里手动停用(disable)此插件。",
|
||||
"syncalgov2_button_agree": "同意",
|
||||
"syncalgov2_button_disagree": "不同意"
|
||||
"syncalgov2_button_disagree": "不同意",
|
||||
|
||||
"official_notice_2024_first_party": "插件 Remotely-Save 回来了,更新了一大堆功能!🎉🎉🎉请自行使用,或参阅更新文档: https://github.com/remotely-save/remotely-save/releases 。"
|
||||
}
|
||||
|
||||
@ -295,5 +295,6 @@
|
||||
"syncalgov2_title": "Remotely Save 的同步演算法得到最佳化",
|
||||
"syncalgov2_texts": "歡迎使用 Remotely Save!\n從版本 0.3.0 開始,它帶來了新的同步演算法,但是,除了您的筆記之外,它還需要上傳額外的帶有元資訊的檔案 _remotely-save-metadata-on-remote.{json,bin} 到您的雲服務目的地上。\n從而,比如說,透過讀取這些資訊,另一臺裝置可以知道什麼檔案或資料夾在第一臺裝置上被刪除了。\n如果您同意此策略,請點選按鈕 \"同意\",然後開始享用此外掛!且特別要注意:使用外掛之前,請首先備份好您的儲存庫(Vault)!\n如果您不同意此策略,您應該停止使用此版本和之後版本的 Remotely Save。您可以考慮手動安裝舊版 0.2.14,它使用舊的同步演算法,並不上傳額外元資訊檔案。點選 \"不同意\" 之後,外掛會自動停止執行(unload),然後您需要 Obsidian 設定裡手動停用(disable)此外掛。",
|
||||
"syncalgov2_button_agree": "同意",
|
||||
"syncalgov2_button_disagree": "不同意"
|
||||
"syncalgov2_button_disagree": "不同意",
|
||||
"official_notice_2024_first_party": "外掛 Remotely-Save 回來了,更新了一大堆功能!🎉🎉🎉請自行使用,或參閱更新文件: https://github.com/remotely-save/remotely-save/releases 。"
|
||||
}
|
||||
|
||||
@ -756,3 +756,25 @@ export const getLastSuccessSyncByVault = async (
|
||||
`${vaultRandomID}-lastSuccessSyncMillis`
|
||||
)) as number;
|
||||
};
|
||||
|
||||
export const upsertPluginVersionByVault = async (
|
||||
db: InternalDBs,
|
||||
vaultRandomID: string,
|
||||
newVersion: string
|
||||
) => {
|
||||
let oldVersion: string | null = await db.simpleKVForMiscTbl.getItem(
|
||||
`${vaultRandomID}-pluginversion`
|
||||
);
|
||||
if (oldVersion === null) {
|
||||
oldVersion = "0.0.0";
|
||||
}
|
||||
await db.simpleKVForMiscTbl.setItem(
|
||||
`${vaultRandomID}-pluginversion`,
|
||||
newVersion
|
||||
);
|
||||
|
||||
return {
|
||||
oldVersion: oldVersion,
|
||||
newVersion: newVersion,
|
||||
};
|
||||
};
|
||||
|
||||
13
src/main.ts
13
src/main.ts
@ -23,6 +23,7 @@ import {
|
||||
COMMAND_CALLBACK_ONEDRIVE,
|
||||
COMMAND_CALLBACK_DROPBOX,
|
||||
COMMAND_URI,
|
||||
REMOTELY_SAVE_VERSION_2024PREPARE,
|
||||
} from "./baseTypes";
|
||||
import { importQrCodeUri } from "./importExport";
|
||||
import {
|
||||
@ -37,6 +38,7 @@ import {
|
||||
clearExpiredSyncPlanRecords,
|
||||
upsertLastSuccessSyncByVault,
|
||||
getLastSuccessSyncByVault,
|
||||
upsertPluginVersionByVault,
|
||||
} from "./localdb";
|
||||
import { RemoteClient } from "./remote";
|
||||
import {
|
||||
@ -72,6 +74,7 @@ import {
|
||||
exportVaultSyncPlansToFiles,
|
||||
} from "./debugMode";
|
||||
import { SizesConflictModal } from "./syncSizesConflictNotice";
|
||||
import { compareVersion } from "./misc";
|
||||
|
||||
const DEFAULT_SETTINGS: RemotelySavePluginSettings = {
|
||||
s3: DEFAULT_S3_CONFIG,
|
||||
@ -822,6 +825,16 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
this.enableInitSyncIfSet();
|
||||
this.enableSyncOnSaveIfSet();
|
||||
}
|
||||
|
||||
// compare versions and read new versions
|
||||
const { oldVersion } = await upsertPluginVersionByVault(
|
||||
this.db,
|
||||
this.vaultRandomID,
|
||||
this.manifest.version
|
||||
);
|
||||
if (compareVersion(REMOTELY_SAVE_VERSION_2024PREPARE, oldVersion) >= 0) {
|
||||
new Notice(t("official_notice_2024_first_party"), 10 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
async onunload() {
|
||||
|
||||
28
src/misc.ts
28
src/misc.ts
@ -455,3 +455,31 @@ export const isFolderToSkip = (x: string, more: string[] | undefined) => {
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param x versionX
|
||||
* @param y versionY
|
||||
* @returns 1(x>y), 0(x==y), -1(x<y)
|
||||
*/
|
||||
export const compareVersion = (x: string | null, y: string | null) => {
|
||||
if (x === undefined || x === null) {
|
||||
return -1;
|
||||
}
|
||||
if (y === undefined || y === null) {
|
||||
return 1;
|
||||
}
|
||||
if (x === y) {
|
||||
return 0;
|
||||
}
|
||||
const [x1, x2, x3] = x.split(".").map((k) => Number(k));
|
||||
const [y1, y2, y3] = y.split(".").map((k) => Number(k));
|
||||
if (
|
||||
x1 > y1 ||
|
||||
(x1 === y1 && x2 > y2) ||
|
||||
(x1 === y1 && x2 === y2 && x3 > y3)
|
||||
) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user