dropbox supports client mtime
This commit is contained in:
parent
942e54961e
commit
c5e3147805
@ -90,9 +90,13 @@ const fromDropboxItemToRemoteItem = (
|
|||||||
etag: `${x.id}\t`,
|
etag: `${x.id}\t`,
|
||||||
} as RemoteItem;
|
} as RemoteItem;
|
||||||
} else if (x[".tag"] === "file") {
|
} else if (x[".tag"] === "file") {
|
||||||
|
let mtime = Date.parse(x.client_modified).valueOf();
|
||||||
|
if (mtime === 0) {
|
||||||
|
mtime = Date.parse(x.server_modified).valueOf();
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
key: key,
|
key: key,
|
||||||
lastModified: Date.parse(x.server_modified).valueOf(),
|
lastModified: mtime,
|
||||||
size: x.size,
|
size: x.size,
|
||||||
remoteType: "dropbox",
|
remoteType: "dropbox",
|
||||||
etag: `${x.id}\t${x.content_hash}`,
|
etag: `${x.id}\t${x.content_hash}`,
|
||||||
@ -518,7 +522,9 @@ export const uploadToRemote = async (
|
|||||||
remoteEncryptedKey: string = "",
|
remoteEncryptedKey: string = "",
|
||||||
foldersCreatedBefore: Set<string> | undefined = undefined,
|
foldersCreatedBefore: Set<string> | undefined = undefined,
|
||||||
uploadRaw: boolean = false,
|
uploadRaw: boolean = false,
|
||||||
rawContent: string | ArrayBuffer = ""
|
rawContent: string | ArrayBuffer = "",
|
||||||
|
rawContentMTime: number = 0,
|
||||||
|
rawContentCTime: number = 0
|
||||||
) => {
|
) => {
|
||||||
await client.init();
|
await client.init();
|
||||||
|
|
||||||
@ -534,6 +540,15 @@ export const uploadToRemote = async (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mtime = 0;
|
||||||
|
let ctime = 0;
|
||||||
|
const s = await vault.adapter.stat(fileOrFolderPath);
|
||||||
|
if (s !== null) {
|
||||||
|
mtime = s.mtime;
|
||||||
|
ctime = s.ctime;
|
||||||
|
}
|
||||||
|
const mtimeStr = new Date(mtime).toISOString().replace(/\.\d{3}Z$/, "Z");
|
||||||
|
|
||||||
const isFolder = fileOrFolderPath.endsWith("/");
|
const isFolder = fileOrFolderPath.endsWith("/");
|
||||||
|
|
||||||
if (isFolder && isRecursively) {
|
if (isFolder && isRecursively) {
|
||||||
@ -579,6 +594,7 @@ export const uploadToRemote = async (
|
|||||||
client.dropbox.filesUpload({
|
client.dropbox.filesUpload({
|
||||||
path: uploadFile,
|
path: uploadFile,
|
||||||
contents: "",
|
contents: "",
|
||||||
|
client_modified: mtimeStr,
|
||||||
}),
|
}),
|
||||||
fileOrFolderPath
|
fileOrFolderPath
|
||||||
);
|
);
|
||||||
@ -612,6 +628,7 @@ export const uploadToRemote = async (
|
|||||||
mode: {
|
mode: {
|
||||||
".tag": "overwrite",
|
".tag": "overwrite",
|
||||||
},
|
},
|
||||||
|
client_modified: mtimeStr,
|
||||||
}),
|
}),
|
||||||
fileOrFolderPath
|
fileOrFolderPath
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user