From 91137ebf8216182d9ff90dd30f74e1553a0a68ec Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Mon, 31 Mar 2025 10:55:15 +0200 Subject: [PATCH] Fix metadata missing --- benchmark.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/benchmark.ts b/benchmark.ts index d512ad8..567c785 100644 --- a/benchmark.ts +++ b/benchmark.ts @@ -72,6 +72,11 @@ const generateRandomFiles = ( maxDepth: number, maxTotalSize: number, ) => { + const metadata: { lastSync: number; files: { [key: string]: {} } } = { + lastSync: 0, + files: {}, + }; + // Create root directory if it doesn't exist if (!fs.existsSync(rootPath)) { fs.mkdirSync(rootPath, { recursive: true }); @@ -136,8 +141,25 @@ const generateRandomFiles = ( fs.writeFileSync(filePath, content); totalSize += contentSize; } + + const relativeFilePath = filePath.replace(`${rootPath}/`, ""); + metadata.files[relativeFilePath] = { + path: relativeFilePath, + sha: null, + dirty: true, + justDownloaded: false, + lastModified: Date.now(), + }; } + const metadataFilePath = path.join( + rootPath, + ".obsidian", + "github-sync-metadata.json", + ); + fs.mkdirSync(path.join(rootPath, ".obsidian")); + fs.writeFileSync(metadataFilePath, JSON.stringify(metadata), { flag: "w" }); + return totalSize; };