fix: fix bugs

This commit is contained in:
hehesheng 2024-06-02 18:57:12 +08:00
parent 361bfdb470
commit 6b7067a8d0
5 changed files with 150 additions and 146 deletions

View File

@ -167,7 +167,9 @@ class MediaChunkHolderManager(object):
def __init__(self) -> None:
self.chunk_lru = collections.OrderedDict()
self.disk_chunk_cache = diskcache.Cache(f"{os.path.dirname(__file__)}/cache_media")
self.disk_chunk_cache = diskcache.Cache(
f"{os.path.dirname(__file__)}/cache_media", size_limit=MediaChunkHolderManager.MAX_CACHE_SIZE
)
self._restore_cache()
def _restore_cache(self) -> None:
@ -178,6 +180,8 @@ class MediaChunkHolderManager(object):
self._set_media_chunk_index(holder.info)
except Exception as err:
logger.warning(f"restore, {err=},{traceback.format_exc()}")
while self.current_cache_size > self.MAX_CACHE_SIZE:
self._remove_pop_chunk()
def get_chunk_holder_by_info(self, info: ChunkInfo) -> MediaChunkHolder:
holder = self.incompleted_chunk.get(info.id)

View File

@ -42,7 +42,7 @@ class TgFileSystemClient(object):
# task should: (task_id, callabledFunc)
task_queue: asyncio.Queue
task_id: int = 0
me: Union[types.User, types.InputPeerUser]
me: Union[types.User, types.InputPeerUser] = None
# client config
client_param: configParse.TgToFileSystemParameter.ClientConfigPatameter

View File

@ -13,5 +13,7 @@ for v in backend_status["clients"]:
if need_login:
import login
login.loop()
else:
import search
search.loop()

View File

@ -4,11 +4,11 @@ import os
import streamlit as st
import qrcode
sys.path.append(os.getcwd() + "/../")
import configParse
import utils
import remote_api as api
@st.experimental_fragment
def loop():
url = api.login_client_by_qr_code_url()
if url is None or url == "":

View File

@ -3,13 +3,11 @@ import os
import streamlit as st
sys.path.append(os.getcwd() + "/../")
import configParse
import utils
import remote_api as api
param = configParse.get_TgToFileSystemParameter()
@st.experimental_fragment
def loop():
if 'page_index' not in st.session_state:
st.session_state.page_index = 1
if 'force_skip' not in st.session_state: