diff --git a/fileshare.py b/fileshare.py index 88650e5..7fc404d 100755 --- a/fileshare.py +++ b/fileshare.py @@ -10,10 +10,9 @@ from tqdm import tqdm from datetime import datetime from math import ceil -# Optimize buffer settings -CHUNK_SIZE = 256 * 1024 # 256KB -MAX_BUFFER = 4 * 1024 * 1024 # 4MB -MIN_CHUNK_SIZE = 32 * 1024 # 32KB +CHUNK_SIZE = 256 * 1024 +MAX_BUFFER = 4 * 1024 * 1024 +MIN_CHUNK_SIZE = 32 * 1024 def format_size(size_bytes): for unit in ['B', 'KB', 'MB', 'GB', 'TB']: @@ -53,7 +52,6 @@ async def file_handler(request): start_time = datetime.now() loop = asyncio.get_running_loop() - # Synchronous file handling with async chunk processing with open(file_path, 'rb') as f: chunk_size = CHUNK_SIZE while True: @@ -61,7 +59,6 @@ async def file_handler(request): if not chunk: break await response.write(chunk) - # Dynamic buffer adjustment chunk_size = min(MAX_BUFFER, max(MIN_CHUNK_SIZE, chunk_size * 2)) duration = (datetime.now() - start_time).total_seconds() @@ -214,7 +211,6 @@ async def main_client(base_url, hash_file, parallel=None, timeout=3600): print("\nšŸŽ‰ All files are up to date!") return - # Dynamic parallelism if parallel is None: parallel = min(ceil(len(download_list)/2), 20) parallel = max(1, min(parallel, 50))