mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 00:04:15 +02:00
[view] fix: single thread downloader does not create the directory where the file will be stored
This commit is contained in:
@@ -6,8 +6,9 @@ import time
|
||||
import traceback
|
||||
from io import StringIO
|
||||
from math import floor
|
||||
from pathlib import Path
|
||||
from threading import Thread
|
||||
from typing import Iterable, List, Tuple
|
||||
from typing import Iterable, List
|
||||
|
||||
from bauh.api.abstract.download import FileDownloader
|
||||
from bauh.api.abstract.handler import ProcessWatcher
|
||||
@@ -130,10 +131,20 @@ class AdaptableFileDownloader(FileDownloader):
|
||||
success = False
|
||||
ti = time.time()
|
||||
try:
|
||||
if output_path and os.path.exists(output_path):
|
||||
self.logger.info(f'Removing old file found before downloading: {output_path}')
|
||||
os.remove(output_path)
|
||||
self.logger.info(f'Old file {output_path} removed')
|
||||
if output_path:
|
||||
if os.path.exists(output_path):
|
||||
self.logger.info(f'Removing old file found before downloading: {output_path}')
|
||||
os.remove(output_path)
|
||||
self.logger.info(f'Old file {output_path} removed')
|
||||
else:
|
||||
output_dir = os.path.dirname(output_path)
|
||||
|
||||
try:
|
||||
Path(output_dir).mkdir(exist_ok=True, parents=True)
|
||||
except OSError:
|
||||
self.logger.error(f"Could not make download directory '{output_dir}'")
|
||||
watcher.print(self.i18n['error.mkdir'].format(dir=output_dir))
|
||||
return False
|
||||
|
||||
client = self.get_available_multithreaded_tool()
|
||||
if client:
|
||||
|
||||
Reference in New Issue
Block a user