1
mirror of https://github.com/thepeacockproject/Peacock synced 2024-11-22 22:12:45 +01:00

Fixed issue where folders for cached images weren't properly created (#9)

This commit is contained in:
Lennard Fonteijn 2022-11-10 21:38:13 +01:00 committed by GitHub
parent 76d6028c5e
commit 9affb237e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -514,6 +514,7 @@ function startServer(options: { hmr: boolean; pluginDevHost: boolean }): void {
join("userdata", "scpc", "steamids"),
join("images", "actors"),
join("images", "contracts"),
join("images", "contracts", "elusive"),
join("images", "contracts", "escalation"),
join("images", "contracts", "featured"),
join("images", "unlockables_override"),

View File

@ -70,6 +70,14 @@ export async function imageFetchingMiddleware(
if (getFlag("imageLoading") === "SAVEASREQUESTED") {
log(LogLevel.DEBUG, `Saving image ${path} to disk.`)
const dir = ppath.dirname(path as Filename)
if (!imageJailFs.existsSync(dir)) {
log(LogLevel.DEBUG, `Creating missing directory ${dir}`)
imageJailFs.mkdirSync(dir, { recursive: true })
}
const writeStream = imageJailFs.createWriteStream(
ppath.resolve(path as Filename),
)