optimize: error handling & update logics

This commit is contained in:
源文雨 2024-04-23 17:06:25 +09:00
parent da9a02049f
commit 1717645ae1
3 changed files with 23 additions and 14 deletions

View File

@ -159,7 +159,7 @@ if __name__ == "__main__":
if not check_all_assets(update=self.config.update):
if self.config.update:
download_all_assets(tmpdir=tmp)
if not check_all_assets(update=False):
if not check_all_assets(update=self.config.update):
printt("counld not satisfy all assets needed.")
exit(1)

View File

@ -60,7 +60,7 @@ if not config.nocheck:
if not check_all_assets(update=config.update):
if config.update:
download_all_assets(tmpdir=tmp)
if not check_all_assets(update=False):
if not check_all_assets(update=config.update):
logging.error("counld not satisfy all assets needed.")
exit(1)
@ -1608,13 +1608,16 @@ with gr.Blocks(title="RVC WebUI") as app:
except:
gr.Markdown(traceback.format_exc())
if config.iscolab:
app.queue(max_size=1022).launch(share=True, max_threads=511)
else:
app.queue(max_size=1022).launch(
max_threads=511,
server_name="0.0.0.0",
inbrowser=not config.noautoopen,
server_port=config.listen_port,
quiet=True,
)
try:
if config.iscolab:
app.queue(max_size=1022).launch(share=True, max_threads=511)
else:
app.queue(max_size=1022).launch(
max_threads=511,
server_name="0.0.0.0",
inbrowser=not config.noautoopen,
server_port=config.listen_port,
quiet=True,
)
except Exception as e:
logger.error(str(e))

View File

@ -28,13 +28,19 @@ def check_model(
return False
with open(target, "rb") as f:
digest = sha256(f)
bakfile = f"{target}.bak"
if digest != hash:
logger.info(f"{target} sha256 hash mismatch.")
logger.warn(f"{target} sha256 hash mismatch.")
logger.info(f"expected: {hash}")
logger.info(f"real val: {digest}")
logger.warn("please add parameter --update to download the latest assets.")
if remove_incorrect:
os.remove(str(target))
if not os.path.exists(bakfile):
os.rename(str(target), bakfile)
else: os.remove(str(target))
return False
if remove_incorrect and os.path.exists(bakfile):
os.remove(bakfile)
return True