fix: webdav secure

This commit is contained in:
administrateur 2025-03-29 18:43:33 +01:00
parent 93b5f85cfd
commit cd6522b99c

View File

@ -7,6 +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
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}")
return
total = int(total)
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
app = Flask(__name__)