Compare commits

...
8 Commits
Author SHA1 Message Date
fyears ea3dcc6533 bump to 0.3.11 2022-03-22 00:56:29 +08:00
fyears c8bd10a855 fix typo 2022-03-22 00:55:44 +08:00
fyears 996074e431 bump to 0.3.10 2022-03-22 00:36:09 +08:00
fyears 275224cf73 full outout for error file 2022-03-22 00:35:18 +08:00
fyears 575a27db26 err msg stays longer 2022-03-22 00:31:17 +08:00
fyears 76127dd131 fix auto depth 2022-03-21 23:34:18 +08:00
fyears e2e6f6a12c a little help for webdav addr 2022-03-21 23:26:09 +08:00
fyears 4f3e8803da more verbose reason for conn fail 2022-03-21 23:04:56 +08:00
11 changed files with 106 additions and 28 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "remotely-save",
"name": "Remotely Save",
"version": "0.3.9",
"version": "0.3.11",
"minAppVersion": "0.13.21",
"description": "Yet another unofficial plugin allowing users to synchronize notes between local device and the cloud service.",
"author": "fyears",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "remotely-save",
"version": "0.3.9",
"version": "0.3.11",
"description": "This is yet another sync plugin for Obsidian app.",
"scripts": {
"dev2": "node esbuild.config.mjs",
+4 -4
View File
@@ -101,11 +101,11 @@ export default class RemotelySavePlugin extends Plugin {
return this.i18n.t(x, vars);
};
const getNotice = (x: string) => {
const getNotice = (x: string, timeout?: number) => {
// only show notices in manual mode
// no notice in auto mode
if (triggerSource === "manual" || triggerSource === "dry") {
new Notice(x);
new Notice(x, timeout);
}
};
if (this.syncStatus !== "idle") {
@@ -331,8 +331,8 @@ export default class RemotelySavePlugin extends Plugin {
});
log.info(msg);
log.info(error);
getNotice(msg);
getNotice(error.message);
getNotice(msg, 10 * 1000);
getNotice(error.message, 10 * 1000);
this.syncStatus = "idle";
if (this.syncRibbon !== undefined) {
setIcon(this.syncRibbon, iconNameSyncWait);
+12 -5
View File
@@ -271,15 +271,22 @@ export class RemoteClient {
}
};
checkConnectivity = async () => {
checkConnectivity = async (callbackFunc?: any) => {
if (this.serviceType === "s3") {
return await s3.checkConnectivity(this.s3Client, this.s3Config);
return await s3.checkConnectivity(
this.s3Client,
this.s3Config,
callbackFunc
);
} else if (this.serviceType === "webdav") {
return await webdav.checkConnectivity(this.webdavClient);
return await webdav.checkConnectivity(this.webdavClient, callbackFunc);
} else if (this.serviceType === "dropbox") {
return await dropbox.checkConnectivity(this.dropboxClient);
return await dropbox.checkConnectivity(this.dropboxClient, callbackFunc);
} else if (this.serviceType === "onedrive") {
return await onedrive.checkConnectivity(this.onedriveClient);
return await onedrive.checkConnectivity(
this.onedriveClient,
callbackFunc
);
} else {
throw Error(`not supported service type ${this.serviceType}`);
}
+8 -3
View File
@@ -636,7 +636,10 @@ export const deleteFromRemote = async (
}
};
export const checkConnectivity = async (client: WrappedDropboxClient) => {
export const checkConnectivity = async (
client: WrappedDropboxClient,
callbackFunc?: any
) => {
try {
const results = await getRemoteMeta(client, "/");
if (results === undefined) {
@@ -644,8 +647,10 @@ export const checkConnectivity = async (client: WrappedDropboxClient) => {
}
return true;
} catch (err) {
console.error("dropbox connectivity error:");
console.error(err);
log.debug(err);
if (callbackFunc !== undefined) {
callbackFunc(err);
}
return false;
}
};
+8 -1
View File
@@ -866,11 +866,18 @@ export const deleteFromRemote = async (
await client.deleteJson(remoteFileName);
};
export const checkConnectivity = async (client: WrappedOnedriveClient) => {
export const checkConnectivity = async (
client: WrappedOnedriveClient,
callbackFunc?: any
) => {
try {
const k = await getUserDisplayName(client);
return k !== "<unknown display name>";
} catch (err) {
log.debug(err);
if (callbackFunc !== undefined) {
callbackFunc(err);
}
return false;
}
};
+11 -1
View File
@@ -498,7 +498,8 @@ export const deleteFromRemote = async (
*/
export const checkConnectivity = async (
s3Client: S3Client,
s3Config: S3Config
s3Config: S3Config,
callbackFunc?: any
) => {
try {
const results = await s3Client.send(
@@ -509,10 +510,19 @@ export const checkConnectivity = async (
results.$metadata === undefined ||
results.$metadata.httpStatusCode === undefined
) {
const err = "results or $metadata or httStatusCode is undefined";
log.debug(err);
if (callbackFunc !== undefined) {
callbackFunc(err);
}
return false;
}
return results.$metadata.httpStatusCode === 200;
} catch (err) {
log.debug(err);
if (callbackFunc !== undefined) {
callbackFunc(err);
}
return false;
}
};
+27 -2
View File
@@ -223,7 +223,7 @@ export class WrappedWebdavClient {
const res = await this.client.customRequest(`/${this.vaultName}`, {
method: "PROPFIND",
headers: {
Depth: "Infinity",
Depth: "infinity",
},
responseType: "text",
});
@@ -523,15 +523,40 @@ export const deleteFromRemote = async (
}
};
export const checkConnectivity = async (client: WrappedWebdavClient) => {
export const checkConnectivity = async (
client: WrappedWebdavClient,
callbackFunc?: any
) => {
if (
!(
client.webdavConfig.address.startsWith("http://") ||
client.webdavConfig.address.startsWith("https://")
)
) {
const err = "Error: the url should start with http(s):// but it does not!";
log.debug(err);
if (callbackFunc !== undefined) {
callbackFunc(err);
}
return false;
}
try {
await client.init();
const results = await getRemoteMeta(client, "/");
if (results === undefined) {
const err = "results is undefined";
log.debug(err);
if (callbackFunc !== undefined) {
callbackFunc(err);
}
return false;
}
return true;
} catch (err) {
log.debug(err);
if (callbackFunc !== undefined) {
callbackFunc(err);
}
return false;
}
};
+20 -4
View File
@@ -826,11 +826,15 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
button.onClick(async () => {
new Notice(t("settings_checkonnectivity_checking"));
const client = new RemoteClient("s3", this.plugin.settings.s3);
const res = await client.checkConnectivity();
const errors = { msg: "" };
const res = await client.checkConnectivity((err: any) => {
errors.msg = err;
});
if (res) {
new Notice(t("settings_s3_connect_succ"));
} else {
new Notice(t("settings_s3_connect_fail"));
new Notice(errors.msg);
}
});
});
@@ -959,11 +963,15 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
() => self.plugin.saveSettings()
);
const res = await client.checkConnectivity();
const errors = { msg: "" };
const res = await client.checkConnectivity((err: any) => {
errors.msg = `${err}`;
});
if (res) {
new Notice(t("settings_dropbox_connect_succ"));
} else {
new Notice(t("settings_dropbox_connect_fail"));
new Notice(errors.msg);
}
});
});
@@ -1074,11 +1082,15 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
() => self.plugin.saveSettings()
);
const res = await client.checkConnectivity();
const errors = { msg: "" };
const res = await client.checkConnectivity((err: any) => {
errors.msg = `${err}`;
});
if (res) {
new Notice(t("settings_onedrive_connect_succ"));
} else {
new Notice(t("settings_onedrive_connect_fail"));
new Notice(errors.msg);
}
});
});
@@ -1230,7 +1242,10 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
this.app.vault.getName(),
() => self.plugin.saveSettings()
);
const res = await client.checkConnectivity();
const errors = { msg: "" };
const res = await client.checkConnectivity((err: any) => {
errors.msg = `${err}`;
});
if (res) {
new Notice(t("settings_webdav_connect_succ"));
} else {
@@ -1244,6 +1259,7 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
corsErrMsg: corsErrMsg,
})
);
new Notice(errors.msg);
}
});
});
+13 -5
View File
@@ -323,7 +323,7 @@ const ensembleMixedStates = async (
r = {
key: entry.path,
existLocal: true,
mtimeLocal: Math.max(entry.stat.mtime, entry.stat.ctime),
mtimeLocal: Math.max(entry.stat.mtime || 0, entry.stat.ctime || 0),
sizeLocal: entry.stat.size,
};
} else if (entry instanceof TFolder) {
@@ -450,22 +450,30 @@ const assignOperationToFileInplace = (
// 0. find anything inconsistent
if (r.existLocal && (r.mtimeLocal === undefined || r.mtimeLocal <= 0)) {
throw Error(
`Error: File ${r.key} has a last modified time <=0 or undefined in the local file system. It's abnormal and the plugin stops.`
`Error: Abnormal last modified time locally: ${JSON.stringify(
r,
null,
2
)}`
);
}
if (r.existRemote && (r.mtimeRemote === undefined || r.mtimeRemote <= 0)) {
throw Error(
`Error: File ${r.key} has a last modified time <=0 or undefined on the remote service. It's abnormal and the plugin stops.`
`Error: Abnormal last modified time remotely: ${JSON.stringify(
r,
null,
2
)}`
);
}
if (r.deltimeLocal !== undefined && r.deltimeLocal <= 0) {
throw Error(
`Error: File ${r.key} has a local deletion time <=0. It's abnormal and the plugin stops.`
`Error: Abnormal deletion time locally: ${JSON.stringify(r, null, 2)}`
);
}
if (r.deltimeRemote !== undefined && r.deltimeRemote <= 0) {
throw Error(
`Error: File ${r.key} has a remote deletion time <=0. It's abnormal and the plugin stops.`
`Error: Abnormal deletion time remotely: ${JSON.stringify(r, null, 2)}`
);
}
+1 -1
View File
@@ -1,4 +1,4 @@
{
"0.3.2": "0.12.15",
"0.3.9": "0.13.21"
"0.3.11": "0.13.21"
}