diff --git a/backend/MediaCacheManager.py b/backend/MediaCacheManager.py index 474c191..5faa77e 100644 --- a/backend/MediaCacheManager.py +++ b/backend/MediaCacheManager.py @@ -148,7 +148,7 @@ class MediaChunkHolder(object): class MediaChunkHolderManager(object): - MAX_CACHE_SIZE = 2**32 # 4GB + MAX_CACHE_SIZE = 2**31 # 2GB current_cache_size: int = 0 # chunk unique id -> ChunkHolder disk_chunk_cache: diskcache.Cache diff --git a/backend/api.py b/backend/api.py index 5849010..9c66ccf 100644 --- a/backend/api.py +++ b/backend/api.py @@ -85,7 +85,7 @@ async def search_tg_file_list(body: TgToFileListRequestBody): chat_id = apiutils.get_message_chat_id_from_dict(msg_info) msg_id = apiutils.get_message_msg_id_from_dict(msg_info) msg_info["file_name"] = file_name - msg_info["download_url"] = f"{param.base.exposed_url}/tg/api/v1/file/get/{chat_id}/{msg_id}/{file_name}" + msg_info["download_url"] = f"{param.base.exposed_url}/tg/api/v1/file/get/{chat_id}/{msg_id}/{quote(file_name)}" msg_info["src_tg_link"] = f"https://t.me/c/{chat_id}/{msg_id}" res_dict.append(msg_info) @@ -127,7 +127,7 @@ async def get_tg_file_list(body: TgToFileListRequestBody): msg_info = json.loads(item.to_json()) msg_info["file_name"] = file_name msg_info["download_url"] = ( - f"{param.base.exposed_url}/tg/api/v1/file/get/{body.chat_id}/{item.id}/{file_name}?sign={body.token}" + f"{param.base.exposed_url}/tg/api/v1/file/get/{body.chat_id}/{item.id}/{quote(file_name)}?sign={body.token}" ) res_dict.append(msg_info) diff --git a/backend/api_implement.py b/backend/api_implement.py index 063dac9..721aae8 100644 --- a/backend/api_implement.py +++ b/backend/api_implement.py @@ -39,7 +39,9 @@ async def link_convert(link: str) -> str: file_name = apiutils.get_message_media_name(msg) param = configParse.get_TgToFileSystemParameter() sign = clients_mgr.generate_sign(client.session_name, EnumSignLevel.VIST) - url = f"{param.base.exposed_url}/tg/api/v1/file/get/{utils.get_peer_id(msg.peer_id)}/{msg.id}/{file_name}?sign={sign}" + url = ( + f"{param.base.exposed_url}/tg/api/v1/file/get/{utils.get_peer_id(msg.peer_id)}/{msg.id}/{quote(file_name)}?sign={sign}" + ) return url