Skip to content

Commit

Permalink
Update cache.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
vHeemstra committed Nov 22, 2023
1 parent f5968a6 commit 43b25b2
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/core/src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async function checkAndUpdate({
buffer,
restoreTo,
}: {
fileName?: string
fileName: string
directory?: string
stats?: Omit<CacheValue, 'hash'>
buffer?: Buffer
Expand All @@ -104,6 +104,12 @@ async function checkAndUpdate({
error?: Error
}> {
if (cacheEnabled) {
if (!fileName) {
return {
error: new Error('Missing filename'),
}
}

const filePath = (directory ?? cacheDir) + fileName

if (!buffer) {
Expand Down Expand Up @@ -172,19 +178,25 @@ export const FileCache = {

update: async ({
fileName,
buffer,
directory,
stats,
buffer,
}: {
fileName?: string
fileName: string
buffer: Buffer
directory?: string
stats?: Omit<CacheValue, 'hash'>
buffer: Buffer
}) => {
if (!cacheEnabled) {
return false
}

if (!fileName) {
return {
error: new Error('Missing filename'),
}
}

if (!buffer) {
return {
error: new Error('Missing content for cache file'),
Expand Down

0 comments on commit 43b25b2

Please sign in to comment.