fix: fix bugs
This commit is contained in:
parent
361bfdb470
commit
6b7067a8d0
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -13,5 +13,7 @@ for v in backend_status["clients"]:
|
||||
|
||||
if need_login:
|
||||
import login
|
||||
login.loop()
|
||||
else:
|
||||
import search
|
||||
search.loop()
|
||||
|
@ -4,21 +4,21 @@ import os
|
||||
import streamlit as st
|
||||
import qrcode
|
||||
|
||||
sys.path.append(os.getcwd() + "/../")
|
||||
import configParse
|
||||
import utils
|
||||
import remote_api as api
|
||||
|
||||
url = api.login_client_by_qr_code_url()
|
||||
@st.experimental_fragment
|
||||
def loop():
|
||||
url = api.login_client_by_qr_code_url()
|
||||
|
||||
if url is None or url == "":
|
||||
if url is None or url == "":
|
||||
st.text("Something wrong, no login url got.")
|
||||
st.stop()
|
||||
|
||||
st.markdown("### Please scan the qr code by telegram client.")
|
||||
qr = qrcode.make(url)
|
||||
st.image(qr.get_image())
|
||||
st.markdown("### Please scan the qr code by telegram client.")
|
||||
qr = qrcode.make(url)
|
||||
st.image(qr.get_image())
|
||||
|
||||
st.markdown("**Click the Refrash button if you have been scaned**")
|
||||
if st.button("Refresh"):
|
||||
st.markdown("**Click the Refrash button if you have been scaned**")
|
||||
if st.button("Refresh"):
|
||||
st.rerun()
|
||||
|
@ -3,27 +3,25 @@ import os
|
||||
|
||||
import streamlit as st
|
||||
|
||||
sys.path.append(os.getcwd() + "/../")
|
||||
import configParse
|
||||
import utils
|
||||
import remote_api as api
|
||||
|
||||
param = configParse.get_TgToFileSystemParameter()
|
||||
|
||||
if 'page_index' not in st.session_state:
|
||||
@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:
|
||||
if 'force_skip' not in st.session_state:
|
||||
st.session_state.force_skip = False
|
||||
|
||||
if 'search_key' not in st.query_params:
|
||||
if 'search_key' not in st.query_params:
|
||||
st.query_params.search_key = ""
|
||||
if 'is_order' not in st.query_params:
|
||||
if 'is_order' not in st.query_params:
|
||||
st.query_params.is_order = False
|
||||
if 'search_res_limit' not in st.query_params:
|
||||
if 'search_res_limit' not in st.query_params:
|
||||
st.query_params.search_res_limit = "10"
|
||||
|
||||
@st.experimental_fragment
|
||||
def search_container():
|
||||
@st.experimental_fragment
|
||||
def search_container():
|
||||
st.query_params.search_key = st.text_input("**搜索🔎**", value=st.query_params.search_key)
|
||||
columns = st.columns([7, 1])
|
||||
with columns[0]:
|
||||
@ -33,19 +31,19 @@ def search_container():
|
||||
st.text("排序")
|
||||
st.query_params.is_order = st.toggle("顺序", value=utils.strtobool(st.query_params.is_order))
|
||||
|
||||
search_container()
|
||||
search_container()
|
||||
|
||||
search_clicked = st.button('Search', type='primary', use_container_width=True)
|
||||
if not st.session_state.force_skip and (not search_clicked or st.query_params.search_key == "" or st.query_params.search_key is None):
|
||||
search_clicked = st.button('Search', type='primary', use_container_width=True)
|
||||
if not st.session_state.force_skip and (not search_clicked or st.query_params.search_key == "" or st.query_params.search_key is None):
|
||||
st.stop()
|
||||
|
||||
if not st.session_state.force_skip:
|
||||
if not st.session_state.force_skip:
|
||||
st.session_state.page_index = 1
|
||||
if st.session_state.force_skip:
|
||||
if st.session_state.force_skip:
|
||||
st.session_state.force_skip = False
|
||||
|
||||
@st.experimental_fragment
|
||||
def do_search_req():
|
||||
@st.experimental_fragment
|
||||
def do_search_req():
|
||||
search_limit = int(st.query_params.search_res_limit)
|
||||
offset_index = (st.session_state.page_index - 1) * search_limit
|
||||
is_order = utils.strtobool(st.query_params.is_order)
|
||||
@ -148,4 +146,4 @@ def do_search_req():
|
||||
show_search_res(search_res)
|
||||
|
||||
|
||||
do_search_req()
|
||||
do_search_req()
|
||||
|
Loading…
x
Reference in New Issue
Block a user