mini support to ctimeCli
This commit is contained in:
parent
b2dea5a351
commit
ac9c2a9248
@ -167,7 +167,7 @@ export async function mergeFile(
|
|||||||
key,
|
key,
|
||||||
newArrayBuffer,
|
newArrayBuffer,
|
||||||
rightEntity.mtimeCli ?? mtime,
|
rightEntity.mtimeCli ?? mtime,
|
||||||
rightEntity.mtimeCli ?? mtime
|
rightEntity.ctimeCli ?? rightEntity.mtimeCli ?? mtime
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -294,13 +294,21 @@ const fromDriveItemToEntity = (x: DriveItem, remoteBaseDir: string): Entity => {
|
|||||||
if (mtimeTry === undefined || mtimeTry === null) {
|
if (mtimeTry === undefined || mtimeTry === null) {
|
||||||
throw Error(`onedrive cannot parse mtime: ${JSON.stringify(x, null, 2)}`);
|
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 mtimeSvr = Date.parse(mtimeTry);
|
||||||
const mtimeCli = Date.parse(mtimeTry);
|
const mtimeCli = Date.parse(mtimeTry);
|
||||||
|
const ctimeCli = Date.parse(ctimeTry);
|
||||||
return {
|
return {
|
||||||
key: key,
|
key: key,
|
||||||
keyRaw: key,
|
keyRaw: key,
|
||||||
mtimeSvr: mtimeSvr,
|
mtimeSvr: mtimeSvr,
|
||||||
mtimeCli: mtimeCli,
|
mtimeCli: mtimeCli,
|
||||||
|
ctimeCli: ctimeCli,
|
||||||
size: isFolder ? 0 : x.size!,
|
size: isFolder ? 0 : x.size!,
|
||||||
sizeRaw: isFolder ? 0 : x.size!,
|
sizeRaw: isFolder ? 0 : x.size!,
|
||||||
synthesizedFile: false,
|
synthesizedFile: false,
|
||||||
@ -771,6 +779,7 @@ export class FakeFsOnedriveFull extends FakeFs {
|
|||||||
keyRaw: origKey,
|
keyRaw: origKey,
|
||||||
mtimeSvr: mtime,
|
mtimeSvr: mtime,
|
||||||
mtimeCli: mtime,
|
mtimeCli: mtime,
|
||||||
|
ctimeCli: ctime,
|
||||||
size: 0,
|
size: 0,
|
||||||
sizeRaw: 0,
|
sizeRaw: 0,
|
||||||
synthesizedFile: true,
|
synthesizedFile: true,
|
||||||
|
|||||||
@ -60,6 +60,17 @@ const copyEntityAndFixTimeFormat = (
|
|||||||
result.mtimeCliFmt = unixTimeToStr(result.mtimeCli);
|
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 !== undefined) {
|
||||||
if (result.mtimeSvr === 0) {
|
if (result.mtimeSvr === 0) {
|
||||||
result.mtimeSvr = undefined;
|
result.mtimeSvr = undefined;
|
||||||
|
|||||||
@ -271,6 +271,8 @@ export interface Entity {
|
|||||||
keyRaw: string;
|
keyRaw: string;
|
||||||
mtimeCli?: number;
|
mtimeCli?: number;
|
||||||
mtimeCliFmt?: string;
|
mtimeCliFmt?: string;
|
||||||
|
ctimeCli?: number;
|
||||||
|
ctimeCliFmt?: string;
|
||||||
mtimeSvr?: number;
|
mtimeSvr?: number;
|
||||||
mtimeSvrFmt?: string;
|
mtimeSvrFmt?: string;
|
||||||
prevSyncTime?: number;
|
prevSyncTime?: number;
|
||||||
|
|||||||
@ -41,7 +41,7 @@ export async function copyFile(key: string, left: FakeFs, right: FakeFs) {
|
|||||||
key,
|
key,
|
||||||
content,
|
content,
|
||||||
statsLeft.mtimeCli,
|
statsLeft.mtimeCli,
|
||||||
statsLeft.mtimeCli /* TODO */
|
statsLeft.ctimeCli ?? statsLeft.mtimeCli
|
||||||
),
|
),
|
||||||
content: content,
|
content: content,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -133,8 +133,10 @@ export class FakeFsLocal extends FakeFs {
|
|||||||
return {
|
return {
|
||||||
key: isFolder ? `${key}/` : key, // local always unencrypted
|
key: isFolder ? `${key}/` : key, // local always unencrypted
|
||||||
keyRaw: isFolder ? `${key}/` : key,
|
keyRaw: isFolder ? `${key}/` : key,
|
||||||
|
ctimeCli: statRes.ctime,
|
||||||
mtimeCli: statRes.mtime,
|
mtimeCli: statRes.mtime,
|
||||||
mtimeSvr: statRes.mtime,
|
mtimeSvr: statRes.mtime,
|
||||||
|
ctimeCliFmt: unixTimeToStr(statRes.ctime),
|
||||||
mtimeCliFmt: unixTimeToStr(statRes.mtime),
|
mtimeCliFmt: unixTimeToStr(statRes.mtime),
|
||||||
mtimeSvrFmt: unixTimeToStr(statRes.mtime),
|
mtimeSvrFmt: unixTimeToStr(statRes.mtime),
|
||||||
size: statRes.size, // local always unencrypted
|
size: statRes.size, // local always unencrypted
|
||||||
|
|||||||
@ -403,13 +403,23 @@ ${constructFromDriveItemToEntityError(x)}`
|
|||||||
if (mtimeTry === undefined || mtimeTry === null) {
|
if (mtimeTry === undefined || mtimeTry === null) {
|
||||||
throw Error(`onedrive cannot parse mtime: ${JSON.stringify(x, null, 2)}`);
|
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 mtimeSvr = Date.parse(mtimeTry);
|
||||||
const mtimeCli = Date.parse(mtimeTry);
|
const mtimeCli = Date.parse(mtimeTry);
|
||||||
|
const ctimeCli = Date.parse(ctimeTry);
|
||||||
return {
|
return {
|
||||||
key: key,
|
key: key,
|
||||||
keyRaw: key,
|
keyRaw: key,
|
||||||
mtimeSvr: mtimeSvr,
|
mtimeSvr: mtimeSvr,
|
||||||
mtimeCli: mtimeCli,
|
mtimeCli: mtimeCli,
|
||||||
|
ctimeCli: ctimeCli,
|
||||||
size: isFolder ? 0 : x.size!,
|
size: isFolder ? 0 : x.size!,
|
||||||
sizeRaw: isFolder ? 0 : x.size!,
|
sizeRaw: isFolder ? 0 : x.size!,
|
||||||
synthesizedFile: false,
|
synthesizedFile: false,
|
||||||
@ -878,6 +888,7 @@ export class FakeFsOnedrive extends FakeFs {
|
|||||||
keyRaw: origKey,
|
keyRaw: origKey,
|
||||||
mtimeSvr: mtime,
|
mtimeSvr: mtime,
|
||||||
mtimeCli: mtime,
|
mtimeCli: mtime,
|
||||||
|
ctimeCli: ctime,
|
||||||
size: 0,
|
size: 0,
|
||||||
sizeRaw: 0,
|
sizeRaw: 0,
|
||||||
synthesizedFile: true,
|
synthesizedFile: true,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user