From 06ee10a862db68f5f3ea886fea74f3e84a51cc49 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Sat, 20 May 2023 08:20:16 +0200 Subject: [PATCH] Fixed a crash while converting the old path --- lib/src/cache.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/src/cache.ts b/lib/src/cache.ts index 346dd7d..7d4adfd 100644 --- a/lib/src/cache.ts +++ b/lib/src/cache.ts @@ -11,16 +11,20 @@ export async function convertOldCachePaths(): Promise { // Convert old cache files to new format // Recursively list all files in the cache folder const cachePath = getCacheBasePath() - const paths = await app.vault.adapter.list(cachePath) - for (const dir of paths.folders) { - const files = await app.vault.adapter.list(dir) - for (const file of files.files) { - const hash = file.split('-').pop()?.split('.').shift() - if (hash) { - const newPath = `${cachePath}/${hash}.json` - await app.vault.adapter.rename(file, newPath) + try { + const paths = await app.vault.adapter.list(cachePath) + for (const dir of paths.folders) { + const files = await app.vault.adapter.list(dir) + for (const file of files.files) { + const hash = file.split('-').pop()?.split('.').shift() + if (hash) { + const newPath = `${cachePath}/${hash}.json` + await app.vault.adapter.rename(file, newPath) + } } } + } catch (e) { + // No old paths to convert } }