Skip to content

Commit

Permalink
The files are no longer damaged when the download is paused.
Browse files Browse the repository at this point in the history
 Changes to be committed:
	modified:   persepolis_lib.py
  • Loading branch information
alireza-amirsamimi committed Sep 26, 2024
1 parent 9730578 commit d80e0fb
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions persepolis_lib/persepolis_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
from persepolis_lib.useful_tools import convertTime, humanReadableSize, convertSize, sendToLog, convertHeaderToDictionary, readCookieJar, getFileNameFromLink
import sys
import json
from urllib.parse import urlparse, unquote
from pathlib import Path
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry

Expand Down Expand Up @@ -603,7 +601,7 @@ def threadHandler(self, thread_number):
* self.python_request_chunk_size)
for data in response.iter_content(
chunk_size=python_request_chunk_size):
if self.download_status == 'downloading':
if self.download_status == 'downloading' or self.download_status == 'paused':
fp.write(data)

# maybe the last chunk is less than default chunk size
Expand Down Expand Up @@ -652,10 +650,10 @@ def threadHandler(self, thread_number):
# receiving loop, which reduces the download speed.
time.sleep(self.sleep_for_speed_limiting)

elif self.download_status == 'paused':
# wait for unpausing
while self.download_status == 'paused':
time.sleep(0.2)
if self.download_status == 'paused':
# wait for unpausing
while self.download_status == 'paused':
time.sleep(0.2)
else:
self.download_infromation_list[part_number][2] = 'stopped'
break
Expand Down

0 comments on commit d80e0fb

Please sign in to comment.