fix: header non supported

This commit is contained in:
administrateur 2025-03-29 19:38:18 +01:00
parent f546480afa
commit c26118e831

View File

@ -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__)