fix: patching webdav client
This commit is contained in:
parent
cd6522b99c
commit
f546480afa
@ -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__)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user