diff --git a/script_creator.py b/script_creator.py index df86cb4..2ea5d12 100644 --- a/script_creator.py +++ b/script_creator.py @@ -7,24 +7,24 @@ import redis import shutil from threading import Lock from webdav3.client import Client -from requests.structures import CaseInsensitiveDict -from webdav3.client import WebDavClient +# ✅ Patch direct de la méthode `download_file` dans Client def safe_download_file(self, remote_path, local_path, progress=None, progress_args=()): response = self.execute_request(action='download', path=remote_path, headers={'accept-encoding': 'identity'}) - total = response.headers.get('content-length') - if total is None: - log_debug(f"⚠️ Skipping file without content-length: {remote_path}") + content_length = response.headers.get('content-length') + if content_length is None: + print(f"⚠️ Skipping file without content-length: {remote_path}") return - total = int(total) + total = int(content_length) + os.makedirs(os.path.dirname(local_path), exist_ok=True) with open(local_path, 'wb') as f: for chunk in response.iter_content(chunk_size=1024): if chunk: f.write(chunk) - log_debug(f"✅ Downloaded file: {remote_path} → {local_path}") -WebDavClient.download_file = safe_download_file +# 🔁 Surcharge +Client.download_file = safe_download_file app = Flask(__name__)