diff --git a/lib.js b/lib.js index 7a213ab..2f8589f 100644 --- a/lib.js +++ b/lib.js @@ -67,6 +67,8 @@ export const doesExist = async (path) => { } catch(err) { exists = false } + + return exists } 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 pathname = view.imageStore.get(basename) - if(isUnset(pathname)) { + if(pathname === undefined) { pathname = downloadImage(images[i], basename, source, view) } @@ -462,6 +464,7 @@ export const createView = async (view = {}) => { await ensureDir(view.path) + console.log(view.imageStoreDirectory) if(view.imageStoreDirectory) await openImageStore(view) @@ -471,7 +474,7 @@ export const createView = async (view = {}) => { export const openImageStore = async view => { let imageStorePath = Path.join(view.path, view.imageStoreDirectory) view.imageStore = new Map() - + if(!await ensureDir(imageStorePath)) { return view }