Skip to content

Commit

Permalink
synced with latest changes from pypdl
Browse files Browse the repository at this point in the history
  • Loading branch information
mjishnu committed Jun 29, 2023
1 parent ea5f2aa commit edb0b0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 9 additions & 2 deletions app/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time
from math import inf
from pathlib import Path
import os

import requests

Expand Down Expand Up @@ -47,7 +48,13 @@ def worker(self):
else:
# gets the size of the file
self.curr = path.stat().st_size
start = self.getval('start') + self.curr
# add the old start size and the current size to get the new start size
start = self.getval("start") + self.curr
# corruption check to make sure parts are not corrupted
if start > end:
os.remove(path)
self.error.set()
print("corrupted file!")

url = self.getval('url')
if self.curr != self.getval('size'):
Expand Down Expand Up @@ -147,7 +154,7 @@ def download(self, url, filepath, num_connections, display, multithread):
# load the progress from the progress file
# the object_hook converts the key strings whose value is int to type int
progress = json.loads(json_file.read_text(), object_hook=lambda d: {
int(k) if k.isdigit() else k: v for k, v in d.items()})
int(k) if k.isdigit() else k: v for k, v in d.items()})
segment = total / num_connections
self._dic['total'] = total
self._dic['connections'] = num_connections
Expand Down
7 changes: 4 additions & 3 deletions app/maingui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import clr
from PyQt6.QtCore import (QObject, QRunnable, Qt, QThreadPool, pyqtSignal,
pyqtSlot)
pyqtSlot)
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QFileDialog, QMainWindow

Expand All @@ -18,7 +18,8 @@
from url_gen import url_generator
from utls import open_browser

dll_path = os.path.abspath(r"data\System.Management.Automation.dll")
script_dir = os.path.dirname(os.path.abspath(__file__))
dll_path = os.path.join(script_dir,"data\System.Management.Automation.dll")
clr.AddReference(dll_path)

try:
Expand Down Expand Up @@ -62,7 +63,7 @@ class Worker(QRunnable):
Inherits from QRunnable to handler worker thread setup, signals and wrap-up.
:param callback: The function callback to run on this worker thread. Supplied args and
kwargs will be passed through to the runner.
kwargs will be passed through to the runner.
:type callback: function
:param args: Arguments to pass to the callback function
:param kwargs: Keywords to pass to the callback function
Expand Down

0 comments on commit edb0b0f

Please sign in to comment.