Skip to content

Commit

Permalink
Fixed a crash while converting the old path
Browse files Browse the repository at this point in the history
  • Loading branch information
scambier committed May 20, 2023
1 parent e0f21a9 commit 06ee10a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ export async function convertOldCachePaths(): Promise<void> {
// 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
}
}

Expand Down

0 comments on commit 06ee10a

Please sign in to comment.