mirror of
https://github.com/remotely-save/remotely-save.git
synced 2024-06-07 21:10:45 +00:00
allow skipping empty file in onedrive
This commit is contained in:
parent
a48440e60b
commit
9d8e2af7b9
@ -89,6 +89,7 @@ export interface OnedriveConfig {
|
|||||||
username: string;
|
username: string;
|
||||||
credentialsShouldBeDeletedAtTime?: number;
|
credentialsShouldBeDeletedAtTime?: number;
|
||||||
remoteBaseDir?: string;
|
remoteBaseDir?: string;
|
||||||
|
emptyFile: "skip" | "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WebdisConfig {
|
export interface WebdisConfig {
|
||||||
@ -230,6 +231,7 @@ export interface Entity {
|
|||||||
hash?: string;
|
hash?: string;
|
||||||
etag?: string;
|
etag?: string;
|
||||||
synthesizedFolder?: boolean;
|
synthesizedFolder?: boolean;
|
||||||
|
synthesizedFile?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UploadedType {
|
export interface UploadedType {
|
||||||
|
@ -32,6 +32,7 @@ export const DEFAULT_ONEDRIVE_CONFIG: OnedriveConfig = {
|
|||||||
deltaLink: "",
|
deltaLink: "",
|
||||||
username: "",
|
username: "",
|
||||||
credentialsShouldBeDeletedAtTime: 0,
|
credentialsShouldBeDeletedAtTime: 0,
|
||||||
|
emptyFile: "skip",
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -344,6 +345,7 @@ const fromDriveItemToEntity = (x: DriveItem, remoteBaseDir: string): Entity => {
|
|||||||
mtimeCli: mtimeCli,
|
mtimeCli: mtimeCli,
|
||||||
size: isFolder ? 0 : x.size!,
|
size: isFolder ? 0 : x.size!,
|
||||||
sizeRaw: isFolder ? 0 : x.size!,
|
sizeRaw: isFolder ? 0 : x.size!,
|
||||||
|
synthesizedFile: false,
|
||||||
// hash: ?? // TODO
|
// hash: ?? // TODO
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -785,7 +787,8 @@ export class FakeFsOnedrive extends FakeFs {
|
|||||||
content,
|
content,
|
||||||
mtime,
|
mtime,
|
||||||
ctime,
|
ctime,
|
||||||
key
|
key,
|
||||||
|
this.onedriveConfig.emptyFile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,12 +797,26 @@ export class FakeFsOnedrive extends FakeFs {
|
|||||||
content: ArrayBuffer,
|
content: ArrayBuffer,
|
||||||
mtime: number,
|
mtime: number,
|
||||||
ctime: number,
|
ctime: number,
|
||||||
origKey: string
|
origKey: string,
|
||||||
|
emptyFile: "skip" | "error"
|
||||||
): Promise<Entity> {
|
): Promise<Entity> {
|
||||||
if (content.byteLength === 0) {
|
if (content.byteLength === 0) {
|
||||||
throw Error(
|
if (emptyFile === "error") {
|
||||||
`${origKey}: Empty file is not allowed in OneDrive, and please write something in it.`
|
throw Error(
|
||||||
);
|
`${origKey}: Empty file is not allowed in OneDrive, and please write something in it.`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
key: origKey,
|
||||||
|
keyRaw: origKey,
|
||||||
|
mtimeSvr: mtime,
|
||||||
|
mtimeCli: mtime,
|
||||||
|
size: 0,
|
||||||
|
sizeRaw: 0,
|
||||||
|
synthesizedFile: true,
|
||||||
|
// hash: ?? // TODO
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ctimeStr = new Date(ctime).toISOString();
|
const ctimeStr = new Date(ctime).toISOString();
|
||||||
|
@ -219,8 +219,12 @@
|
|||||||
"settings_onedrive_auth": "Auth",
|
"settings_onedrive_auth": "Auth",
|
||||||
"settings_onedrive_auth_desc": "Auth.",
|
"settings_onedrive_auth_desc": "Auth.",
|
||||||
"settings_onedrive_auth_button": "Auth",
|
"settings_onedrive_auth_button": "Auth",
|
||||||
"settings_onedrive_connect_succ": "Great! We can connect to Onedrive!",
|
"settings_onedrive_connect_succ": "Great! We can connect to OneDrive!",
|
||||||
"settings_onedrive_connect_fail": "We cannot connect to Onedrive.",
|
"settings_onedrive_connect_fail": "We cannot connect to OneDrive.",
|
||||||
|
"settings_onedrive_emptyfile": "Empty File Handling",
|
||||||
|
"settings_onedrive_emptyfile_desc": "OneDrive doesn't allow uploading empty file (even in its official website). Do you want to show up errors or silently skip the empty files?",
|
||||||
|
"settings_onedrive_emptyfile_skip": "Skip",
|
||||||
|
"settings_onedrive_emptyfile_error": "Error and abort",
|
||||||
"settings_webdav": "Remote For Webdav",
|
"settings_webdav": "Remote For Webdav",
|
||||||
"settings_webdav_disclaimer1": "Disclaimer: The information is stored locally. Other malicious/harmful/faulty plugins may read the info. If you see any unintentional access to your webdav server, please immediately change the username and password.",
|
"settings_webdav_disclaimer1": "Disclaimer: The information is stored locally. Other malicious/harmful/faulty plugins may read the info. If you see any unintentional access to your webdav server, please immediately change the username and password.",
|
||||||
"settings_webdav_cors_os": "Obsidian desktop>=0.13.25 or iOS>=1.1.1 or Android>=1.2.1 supports bypassing CORS locally. But you are using an old version, and you're suggested to upgrade Obsidian.",
|
"settings_webdav_cors_os": "Obsidian desktop>=0.13.25 or iOS>=1.1.1 or Android>=1.2.1 supports bypassing CORS locally. But you are using an old version, and you're suggested to upgrade Obsidian.",
|
||||||
|
@ -220,6 +220,10 @@
|
|||||||
"settings_onedrive_auth_button": "鉴权",
|
"settings_onedrive_auth_button": "鉴权",
|
||||||
"settings_onedrive_connect_succ": "很好!我们可连接上 OneDrive!",
|
"settings_onedrive_connect_succ": "很好!我们可连接上 OneDrive!",
|
||||||
"settings_onedrive_connect_fail": "我们未能连接上 OneDrive。",
|
"settings_onedrive_connect_fail": "我们未能连接上 OneDrive。",
|
||||||
|
"settings_onedrive_emptyfile": "空文件处理",
|
||||||
|
"settings_onedrive_emptyfile_desc": "OneDrive 不允许上传空文件(即使官网也是不允许的)。那么你想跳过空文件还是返回错误?",
|
||||||
|
"settings_onedrive_emptyfile_skip": "跳过",
|
||||||
|
"settings_onedrive_emptyfile_error": "返回错误和中断",
|
||||||
"settings_webdav": "Webdav 设置",
|
"settings_webdav": "Webdav 设置",
|
||||||
"settings_webdav_disclaimer1": "声明:您所输入的信息存储于本地。其它有害的或者出错的插件,是有可能读取到这些信息的。如果您发现了 Webdav 服务器有不符合预期的访问,请立刻修改用户名和密码。",
|
"settings_webdav_disclaimer1": "声明:您所输入的信息存储于本地。其它有害的或者出错的插件,是有可能读取到这些信息的。如果您发现了 Webdav 服务器有不符合预期的访问,请立刻修改用户名和密码。",
|
||||||
"settings_webdav_cors_os": "Obsidian 桌面版>=0.13.25 或 iOS>=1.1.1 或 Android>=1.2.1 支持跳过 CORS 设置。但您正在使用旧版,建议升级。",
|
"settings_webdav_cors_os": "Obsidian 桌面版>=0.13.25 或 iOS>=1.1.1 或 Android>=1.2.1 支持跳过 CORS 设置。但您正在使用旧版,建议升级。",
|
||||||
|
@ -219,6 +219,10 @@
|
|||||||
"settings_onedrive_auth_button": "鑑權",
|
"settings_onedrive_auth_button": "鑑權",
|
||||||
"settings_onedrive_connect_succ": "很好!我們可連線上 OneDrive!",
|
"settings_onedrive_connect_succ": "很好!我們可連線上 OneDrive!",
|
||||||
"settings_onedrive_connect_fail": "我們未能連線上 OneDrive。",
|
"settings_onedrive_connect_fail": "我們未能連線上 OneDrive。",
|
||||||
|
"settings_onedrive_emptyfile": "空檔案處理",
|
||||||
|
"settings_onedrive_emptyfile_desc": "OneDrive 不允許上傳空檔案(即使官網也是不允許的)。那麼你想跳過空檔案還是返回錯誤?",
|
||||||
|
"settings_onedrive_emptyfile_skip": "跳過",
|
||||||
|
"settings_onedrive_emptyfile_error": "返回錯誤和中斷",
|
||||||
"settings_webdav": "Webdav 設定",
|
"settings_webdav": "Webdav 設定",
|
||||||
"settings_webdav_disclaimer1": "宣告:您所輸入的資訊儲存於本地。其它有害的或者出錯的外掛,是有可能讀取到這些資訊的。如果您發現了 Webdav 伺服器有不符合預期的訪問,請立刻修改使用者名稱和密碼。",
|
"settings_webdav_disclaimer1": "宣告:您所輸入的資訊儲存於本地。其它有害的或者出錯的外掛,是有可能讀取到這些資訊的。如果您發現了 Webdav 伺服器有不符合預期的訪問,請立刻修改使用者名稱和密碼。",
|
||||||
"settings_webdav_cors_os": "Obsidian 桌面版>=0.13.25 或 iOS>=1.1.1 或 Android>=1.1.1 支援跳過 CORS 設定。但您正在使用舊版,建議升級。",
|
"settings_webdav_cors_os": "Obsidian 桌面版>=0.13.25 或 iOS>=1.1.1 或 Android>=1.1.1 支援跳過 CORS 設定。但您正在使用舊版,建議升級。",
|
||||||
|
@ -855,6 +855,9 @@ export default class RemotelySavePlugin extends Plugin {
|
|||||||
if (this.settings.onedrive.remoteBaseDir === undefined) {
|
if (this.settings.onedrive.remoteBaseDir === undefined) {
|
||||||
this.settings.onedrive.remoteBaseDir = "";
|
this.settings.onedrive.remoteBaseDir = "";
|
||||||
}
|
}
|
||||||
|
if (this.settings.onedrive.emptyFile === undefined) {
|
||||||
|
this.settings.onedrive.emptyFile = "skip";
|
||||||
|
}
|
||||||
if (this.settings.webdav.manualRecursive === undefined) {
|
if (this.settings.webdav.manualRecursive === undefined) {
|
||||||
this.settings.webdav.manualRecursive = true;
|
this.settings.webdav.manualRecursive = true;
|
||||||
}
|
}
|
||||||
|
@ -1418,6 +1418,20 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
new Setting(onedriveDiv)
|
||||||
|
.setName(t("settings_onedrive_emptyfile"))
|
||||||
|
.setDesc(t("settings_onedrive_emptyfile_desc"))
|
||||||
|
.addDropdown(async (dropdown) => {
|
||||||
|
dropdown
|
||||||
|
.addOption("skip", t("settings_onedrive_emptyfile_skip"))
|
||||||
|
.addOption("error", t("settings_onedrive_emptyfile_error"))
|
||||||
|
.setValue(this.plugin.settings.onedrive.emptyFile)
|
||||||
|
.onChange(async (val) => {
|
||||||
|
this.plugin.settings.onedrive.emptyFile = val as any;
|
||||||
|
await this.plugin.saveSettings();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
new Setting(onedriveDiv)
|
new Setting(onedriveDiv)
|
||||||
.setName(t("settings_checkonnectivity"))
|
.setName(t("settings_checkonnectivity"))
|
||||||
.setDesc(t("settings_checkonnectivity_desc"))
|
.setDesc(t("settings_checkonnectivity_desc"))
|
||||||
|
Loading…
Reference in New Issue
Block a user