From c26118e83177878f0c816f0007a6c1a53a026234 Mon Sep 17 00:00:00 2001 From: administrateur Date: Sat, 29 Mar 2025 19:38:18 +0100 Subject: [PATCH] fix: header non supported --- script_creator.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/script_creator.py b/script_creator.py index 2ea5d12..63db9de 100644 --- a/script_creator.py +++ b/script_creator.py @@ -8,22 +8,24 @@ import shutil from threading import Lock from webdav3.client import Client -# ✅ 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'}) - content_length = response.headers.get('content-length') + url = self.get_url(remote_path) + response = self.session.get(url, stream=True, headers={"Accept-Encoding": "identity"}) + content_length = response.headers.get("Content-Length") + if content_length is None: print(f"⚠️ Skipping file without content-length: {remote_path}") return - total = int(content_length) + total = int(content_length) os.makedirs(os.path.dirname(local_path), exist_ok=True) - with open(local_path, 'wb') as f: + + with open(local_path, "wb") as f: for chunk in response.iter_content(chunk_size=1024): if chunk: f.write(chunk) -# 🔁 Surcharge +# 🩹 Patch de la méthode originale Client.download_file = safe_download_file app = Flask(__name__)