From e708c90387783c84f1092fb7d11906e127e4c10c Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Tue, 14 May 2024 12:41:34 +0300 Subject: Limit IG download time to 5min --- src/instagram_task.ts | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/instagram_task.ts b/src/instagram_task.ts index 4e31518..5777a56 100644 --- a/src/instagram_task.ts +++ b/src/instagram_task.ts @@ -105,10 +105,16 @@ export const runDownloadInstagramTask = async (task: InstagramTask) => { console.log("Waiting for download to start"); await wait(3000); + let downloadTimeout = 5 * 60 * 1000; // 5 minutes let downloadedFiles = fs.readdirSync("./downloads"); while (downloadedFiles.some((file) => file.endsWith(".crdownload"))) { + if (downloadTimeout <= 0) { + throw new Error("Download timed out"); + } + console.log("Download still in progress, waiting"); await wait(1000); + downloadTimeout -= 1000; downloadedFiles = fs.readdirSync("./downloads"); } -- cgit v1.3