Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance cachePurgeMosaic to remove mosaic256 as well #81

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/cache.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,21 @@ async function cacheInit() {
}
}

function cachePurgeMosaic() {
return fs.promises.rmdir(`${TILES_CACHE_DIR_PATH}/__mosaic__`);
async function cachePurgeMosaic() {
try {
await Promise.all([
fs.promises.rmdir(`${TILES_CACHE_DIR_PATH}/__mosaic__`, { recursive: true }),
fs.promises.rmdir(`${TILES_CACHE_DIR_PATH}/__mosaic256__`, { recursive: true })
dqunbp marked this conversation as resolved.
Show resolved Hide resolved
]);
// Recreate directories to maintain consistency with cacheInit
await Promise.all([
fs.promises.mkdir(`${TILES_CACHE_DIR_PATH}/__mosaic__`, { recursive: true }),
fs.promises.mkdir(`${TILES_CACHE_DIR_PATH}/__mosaic256__`, { recursive: true })
]);
} catch (error) {
throw new Error(`Failed to purge mosaic cache: ${error.message}`);
}
}
dqunbp marked this conversation as resolved.
Show resolved Hide resolved
}

function mosaicTilesIterable() {
Expand Down