Fixed an error with file access checking that was causing the image store to report as empty

This commit is contained in:
Dakedres 2024-04-11 13:29:18 -06:00
parent 8904e4225e
commit d2469e63f9

7
lib.js
View File

@ -67,6 +67,8 @@ export const doesExist = async (path) => {
} catch(err) { } catch(err) {
exists = false exists = false
} }
return exists
} }
export const ensureDir = async (path) => { export const ensureDir = async (path) => {
@ -409,7 +411,7 @@ export const downloadImages = (images, source, postId, view) => {
let basename = images.length > 1 ? basePath + '-' + i : basePath let basename = images.length > 1 ? basePath + '-' + i : basePath
let pathname = view.imageStore.get(basename) let pathname = view.imageStore.get(basename)
if(isUnset(pathname)) { if(pathname === undefined) {
pathname = downloadImage(images[i], basename, source, view) pathname = downloadImage(images[i], basename, source, view)
} }
@ -462,6 +464,7 @@ export const createView = async (view = {}) => {
await ensureDir(view.path) await ensureDir(view.path)
console.log(view.imageStoreDirectory)
if(view.imageStoreDirectory) if(view.imageStoreDirectory)
await openImageStore(view) await openImageStore(view)
@ -471,7 +474,7 @@ export const createView = async (view = {}) => {
export const openImageStore = async view => { export const openImageStore = async view => {
let imageStorePath = Path.join(view.path, view.imageStoreDirectory) let imageStorePath = Path.join(view.path, view.imageStoreDirectory)
view.imageStore = new Map() view.imageStore = new Map()
if(!await ensureDir(imageStorePath)) { if(!await ensureDir(imageStorePath)) {
return view return view
} }