Skip to content

Commit 39f9d2e

Browse files
zh3036claude
andcommitted
fix: migrate sync status storage from makeSandboxStorage to settings API
Replace logseq.Assets.makeSandboxStorage() with logseq.settings to store sync status. This fixes the "BUG: should not join with empty dir" error that occurs when Logseq tries to construct storage paths with empty base directories. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 907f264 commit 39f9d2e

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

src/settings.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,12 @@ export default function settingSchema() {
163163
description: "Flat all your result.",
164164
default: false,
165165
},
166+
{
167+
key: "syncStatus",
168+
type: "object",
169+
title: "Sync Status (Internal Use)",
170+
description: "Internal sync status tracking - DO NOT MODIFY",
171+
default: { lastSyncId: 0 },
172+
},
166173
]);
167174
}

src/utils.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,20 @@ export const getMemoId = (properties: Record<string, any>): number | null => {
5959
};
6060

6161
export const saveSyncStatus = async (lastSyncId: number) => {
62-
const s = logseq.Assets.makeSandboxStorage();
63-
await s.setItem(
64-
"syncStatus.json",
65-
JSON.stringify({ lastSyncId: lastSyncId })
66-
);
62+
await logseq.updateSettings({
63+
syncStatus: { lastSyncId: lastSyncId }
64+
});
6765
};
6866

6967
export const fetchSyncStatus = async (
7068
): Promise<{ lastSyncId: number }> => {
71-
const s = logseq.Assets.makeSandboxStorage();
7269
try {
73-
const syncStatusString = await s.getItem("syncStatus.json");
74-
return JSON.parse(syncStatusString!);
70+
const settings = logseq.settings;
71+
if (settings?.syncStatus && typeof settings.syncStatus.lastSyncId === 'number') {
72+
return settings.syncStatus;
73+
}
74+
return { lastSyncId: 0 };
7575
} catch (error) {
76-
return {lastSyncId : 0};
76+
return { lastSyncId: 0 };
7777
}
7878
};

0 commit comments

Comments
 (0)