Compare commits

...
2 Commits
Author SHA1 Message Date
fyears f2794ac539 bump to beta 0.4.2
Release A New Version / build (16.x) (push) Failing after 40s
2024-03-18 00:46:02 +08:00
fyears 519fd27dd5 fix s3 time 2024-03-18 00:45:28 +08:00
4 changed files with 29 additions and 12 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "remotely-save",
"name": "Remotely Save",
"version": "0.4.1",
"version": "0.4.2",
"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.4.1",
"version": "0.4.2",
"description": "This is yet another sync plugin for Obsidian app.",
"scripts": {
"dev2": "node esbuild.config.mjs --watch",
+3 -3
View File
@@ -257,7 +257,7 @@ const fromS3HeadObjectToEntity = (
const mtimeSvr = Math.floor(x.LastModified!.valueOf() / 1000.0) * 1000;
let mtimeCli = mtimeSvr;
if (x.Metadata !== undefined) {
const m2 = Math.round(
const m2 = Math.floor(
parseFloat(x.Metadata.mtime || x.Metadata.MTime || "0")
);
if (m2 !== 0) {
@@ -539,12 +539,12 @@ const listFromRemoteRaw = async (
if (rspHead.Metadata === undefined) {
// pass
} else {
mtimeRecords[content.Key!] = Math.round(
mtimeRecords[content.Key!] = Math.floor(
parseFloat(
rspHead.Metadata.mtime || rspHead.Metadata.MTime || "0"
)
);
ctimeRecords[content.Key!] = Math.round(
ctimeRecords[content.Key!] = Math.floor(
parseFloat(
rspHead.Metadata.ctime || rspHead.Metadata.CTime || "0"
)
+24 -7
View File
@@ -5,6 +5,7 @@ import type {
EmptyFolderCleanType,
Entity,
MixedEntity,
SUPPORTED_SERVICES_TYPE,
SyncDirectionType,
} from "./baseTypes";
import { isInsideObsFolder } from "./obsFolderLister";
@@ -186,12 +187,19 @@ const isSkipItemByName = (
);
};
const copyEntityAndFixTimeFormat = (src: Entity) => {
const copyEntityAndFixTimeFormat = (
src: Entity,
serviceType: SUPPORTED_SERVICES_TYPE
) => {
const result = Object.assign({}, src);
if (result.mtimeCli !== undefined) {
if (result.mtimeCli === 0) {
result.mtimeCli = undefined;
} else {
if (serviceType === "s3") {
// round to second instead of millisecond
result.mtimeCli = Math.floor(result.mtimeCli / 1000.0) * 1000;
}
result.mtimeCliFmt = unixTimeToStr(result.mtimeCli);
}
}
@@ -199,6 +207,10 @@ const copyEntityAndFixTimeFormat = (src: Entity) => {
if (result.mtimeSvr === 0) {
result.mtimeSvr = undefined;
} else {
if (serviceType === "s3") {
// round to second instead of millisecond
result.mtimeSvr = Math.floor(result.mtimeSvr / 1000.0) * 1000;
}
result.mtimeSvrFmt = unixTimeToStr(result.mtimeSvr);
}
}
@@ -206,6 +218,10 @@ const copyEntityAndFixTimeFormat = (src: Entity) => {
if (result.prevSyncTime === 0) {
result.prevSyncTime = undefined;
} else {
if (serviceType === "s3") {
// round to second instead of millisecond
result.prevSyncTime = Math.floor(result.prevSyncTime / 1000.0) * 1000;
}
result.prevSyncTimeFmt = unixTimeToStr(result.prevSyncTime);
}
}
@@ -361,7 +377,8 @@ export const ensembleMixedEnties = async (
configDir: string,
syncUnderscoreItems: boolean,
ignorePaths: string[],
password: string
password: string,
serviceType: SUPPORTED_SERVICES_TYPE
): Promise<SyncPlanType> => {
const finalMappings: SyncPlanType = {};
@@ -369,7 +386,7 @@ export const ensembleMixedEnties = async (
for (const remote of remoteEntityList) {
const remoteCopied = ensureMTimeOfRemoteEntityValid(
await decryptRemoteEntityInplace(
copyEntityAndFixTimeFormat(remote),
copyEntityAndFixTimeFormat(remote, serviceType),
password
)
);
@@ -418,14 +435,14 @@ export const ensembleMixedEnties = async (
if (finalMappings.hasOwnProperty(key)) {
const prevSyncCopied = await encryptLocalEntityInplace(
copyEntityAndFixTimeFormat(prevSync),
copyEntityAndFixTimeFormat(prevSync, serviceType),
password,
finalMappings[key].remote?.keyEnc
);
finalMappings[key].prevSync = prevSyncCopied;
} else {
const prevSyncCopied = await encryptLocalEntityInplace(
copyEntityAndFixTimeFormat(prevSync),
copyEntityAndFixTimeFormat(prevSync, serviceType),
password,
undefined
);
@@ -456,14 +473,14 @@ export const ensembleMixedEnties = async (
if (finalMappings.hasOwnProperty(key)) {
const localCopied = await encryptLocalEntityInplace(
copyEntityAndFixTimeFormat(local),
copyEntityAndFixTimeFormat(local, serviceType),
password,
finalMappings[key].remote?.keyEnc
);
finalMappings[key].local = localCopied;
} else {
const localCopied = await encryptLocalEntityInplace(
copyEntityAndFixTimeFormat(local),
copyEntityAndFixTimeFormat(local, serviceType),
password,
undefined
);