mini support to ctimeCli

This commit is contained in:
fyears
2024-09-01 17:17:08 +08:00
parent b2dea5a351
commit ac9c2a9248
7 changed files with 37 additions and 2 deletions
+1 -1
View File
@@ -167,7 +167,7 @@ export async function mergeFile(
key,
newArrayBuffer,
rightEntity.mtimeCli ?? mtime,
rightEntity.mtimeCli ?? mtime
rightEntity.ctimeCli ?? rightEntity.mtimeCli ?? mtime
);
return {
+9
View File
@@ -294,13 +294,21 @@ const fromDriveItemToEntity = (x: DriveItem, remoteBaseDir: string): Entity => {
if (mtimeTry === undefined || mtimeTry === null) {
throw Error(`onedrive cannot parse mtime: ${JSON.stringify(x, null, 2)}`);
}
let ctimeTry = x?.fileSystemInfo?.createdDateTime;
if (ctimeTry === undefined || ctimeTry === null) {
// throw Error(`onedrive cannot parse ctime: ${JSON.stringify(x, null, 2)}`);
// it doesn't hurt, we just use mtimeTry to fullfill
ctimeTry = mtimeTry;
}
const mtimeSvr = Date.parse(mtimeTry);
const mtimeCli = Date.parse(mtimeTry);
const ctimeCli = Date.parse(ctimeTry);
return {
key: key,
keyRaw: key,
mtimeSvr: mtimeSvr,
mtimeCli: mtimeCli,
ctimeCli: ctimeCli,
size: isFolder ? 0 : x.size!,
sizeRaw: isFolder ? 0 : x.size!,
synthesizedFile: false,
@@ -771,6 +779,7 @@ export class FakeFsOnedriveFull extends FakeFs {
keyRaw: origKey,
mtimeSvr: mtime,
mtimeCli: mtime,
ctimeCli: ctime,
size: 0,
sizeRaw: 0,
synthesizedFile: true,
+11
View File
@@ -60,6 +60,17 @@ const copyEntityAndFixTimeFormat = (
result.mtimeCliFmt = unixTimeToStr(result.mtimeCli);
}
}
if (result.ctimeCli !== undefined) {
if (result.ctimeCli === 0) {
result.ctimeCli = undefined;
} else {
if (serviceType === "s3" || serviceType === "dropbox") {
// round to second instead of millisecond
result.ctimeCli = Math.floor(result.ctimeCli / 1000.0) * 1000;
}
result.ctimeCliFmt = unixTimeToStr(result.ctimeCli);
}
}
if (result.mtimeSvr !== undefined) {
if (result.mtimeSvr === 0) {
result.mtimeSvr = undefined;