diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2024-05-14 12:41:34 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2024-05-14 12:41:34 +0300 |
| commit | e708c90387783c84f1092fb7d11906e127e4c10c (patch) | |
| tree | 28e5ec02ecd23be78f29148d68629e3f33bcbe7c | |
| parent | dc9b4e6af1b6b90c0e69fec1e2499ab8548d9347 (diff) | |
Limit IG download time to 5min
| -rw-r--r-- | src/instagram_task.ts | 6 |
1 files changed, 6 insertions, 0 deletions
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"); } |
