Fix indexeddb file system readdir to use a range

This commit is contained in:
Misode
2024-11-26 18:04:11 +01:00
parent 46ed105c34
commit 6badc9f06f
7 changed files with 20 additions and 19 deletions

View File

@@ -1,3 +1,4 @@
import type { ExternalFileSystem } from '@spyglassmc/core'
import * as zip from '@zip.js/zip.js'
import type { Identifier, NbtTag, Random } from 'deepslate'
import { Matrix3, Matrix4, NbtByte, NbtCompound, NbtDouble, NbtInt, NbtList, NbtString, Vector } from 'deepslate'
@@ -635,3 +636,12 @@ export function safeJsonParse(text: string): any {
return undefined
}
}
export async function clearFolder(fs: ExternalFileSystem, uri: string) {
const entries = await fs.readdir(uri)
return Promise.all(entries.map(async e => {
if (e.name !== uri) {
return await fs.unlink(e.name)
}
}))
}