mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-25 23:16:27 -08:00
automatically generate directories with new DbFile system
This commit is contained in:
parent
37f88d6984
commit
93b277e5b8
|
@ -57,14 +57,6 @@ if (config.forceSSL) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// funcs
|
|
||||||
|
|
||||||
// init data
|
|
||||||
|
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
||||||
if (!fs.existsSync(__dirname + "/../.data/"))
|
|
||||||
fs.mkdirSync(__dirname + "/../.data/")
|
|
||||||
|
|
||||||
// discord
|
// discord
|
||||||
let files = new Files(config)
|
let files = new Files(config)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { readFile, writeFile, rename, readdir } from "fs/promises"
|
import { readFile, writeFile, readdir, mkdir } from "fs/promises"
|
||||||
|
import { existsSync } from "fs"
|
||||||
import path from "node:path"
|
import path from "node:path"
|
||||||
|
|
||||||
const DATADIR = `./.data`
|
const DATADIR = `./.data`
|
||||||
|
@ -92,6 +93,11 @@ export default class DbFile<Structure extends ({}|[])> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async findAvailable() {
|
private async findAvailable() {
|
||||||
|
// would it be worth it to remove existsSync here?
|
||||||
|
// mkdir seems to already do it itself when recursive is true
|
||||||
|
if (!existsSync(DATADIR))
|
||||||
|
await mkdir(DATADIR, { recursive: true })
|
||||||
|
|
||||||
return (await readdir(DATADIR))
|
return (await readdir(DATADIR))
|
||||||
.filter(e => e.match(new RegExp(`^${this.name}(?:-b)?.json$`)))
|
.filter(e => e.match(new RegExp(`^${this.name}(?:-b)?.json$`)))
|
||||||
.map(e => path.join(DATADIR, e))
|
.map(e => path.join(DATADIR, e))
|
||||||
|
|
Loading…
Reference in a new issue