Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
fix(s3): fix downloads from s3
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Apr 24, 2024
1 parent 4e1dabe commit 27e0567
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,17 @@ export const fetchCacheFromS3 = async () => {

const tmpFileDir = path.dirname(tempFilePath);
const finalFilePath = path.join(process.cwd(), fileKey);
const warpCacheDir = path.dirname(finalFilePath);

try {
if (fs.existsSync(fileKey)) {
if (!fs.existsSync(tmpFileDir)) {
await fs.promises.mkdir(tmpFileDir, { recursive: true });
}

if (!fs.existsSync(warpCacheDir)) {
await fs.promises.mkdir(warpCacheDir, { recursive: true });
}

const data = await s3.send(
new GetObjectCommand({ ...params, Key: fileKey }),
);
Expand All @@ -184,8 +189,6 @@ export const fetchCacheFromS3 = async () => {
tempFilePath,
});
await fs.promises.writeFile(tempFilePath, readableStream);
const warpCacheDir = path.dirname(finalFilePath);
await fs.promises.mkdir(warpCacheDir, { recursive: true });
if (fs.existsSync(finalFilePath)) {
await fs.promises.unlink(finalFilePath);
}
Expand Down

0 comments on commit 27e0567

Please sign in to comment.