Skip to content

Commit

Permalink
Only sync down files that are marked sync
Browse files Browse the repository at this point in the history
Signed-off-by: Daishan Peng <[email protected]>
  • Loading branch information
StrongMonkey committed Sep 6, 2024
1 parent ff60e6a commit bc16f3b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ async function main() {
let metadata: Map<string, {
url: string;
updatedAt: string;
sync: boolean;
}> = new Map();
const outputDir = path.join(process.env.WORKSPACE_DIR!!, 'knowledge', 'integrations', 'notion');
await mkdir(outputDir, { recursive: true });
Expand All @@ -70,14 +71,23 @@ async function main() {
let updatedPages = 0;
for (const page of pages) {
if (metadata.has(page.id)) {
if (metadata.get(page.id)!.updatedAt === page.last_edited_time) {
const entry = metadata.get(page.id)
if (entry?.updatedAt === page.last_edited_time) {
continue;
}
if (entry?.sync) {
await writePageToFile(page, outputDir);
}
metadata.set(page.id, {
url: page.url,
updatedAt: page.last_edited_time,
sync: entry?.sync ?? false,
})
}
await writePageToFile(page, outputDir);
metadata.set(page.id, {
url: page.url,
updatedAt: page.last_edited_time,
sync: false,
})
updatedPages++
}
Expand Down

0 comments on commit bc16f3b

Please sign in to comment.