Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: 数据库读取保存逻辑 #26

Open
welann opened this issue Nov 7, 2023 · 1 comment
Open

Bug: 数据库读取保存逻辑 #26

welann opened this issue Nov 7, 2023 · 1 comment
Labels
bug Something isn't working P0 highest priority

Comments

@welann
Copy link

welann commented Nov 7, 2023

具体表现为无法保存并读取最新的数据

当前目录下共有三份文件welann_2023-11_wind_TEMP_READ.db welann_2023-11_wind_TEMP_READ1.db welann_2023-11_wind.db

其中 welann_2023-11_wind_TEMP_READ.db 为我把原本这个名字的文件命名为 welann_2023-11_wind_TEMP_READ1.db 后,复制welann_2023-11_wind.db 改名后的文件,此时webui上可以正常显示内容

那么为什么原本的 TEMP_READ 数据库得不到更新呢?
我现在使用的代码是最新版本的

球球你们把几百行上千行的代码拆一下吧(

更新:我把 TEMP_READ 删除后也可以正常出现新的 TEMP_READ文件,不知道之前的情况是代码中的哪个部分出错

不如每次都把目录下不合规的文件全删了,然后再生成 TEMP_READ 文件😈

@Antonoko
Copy link
Collaborator

Antonoko commented Nov 7, 2023

RD 大佬在重构了在重构了.jpg 🧎‍♀️

目前 webui 生成 _TEMP_READ.db 临时读取用数据库的逻辑是:

  1. 当检测到 start_record.bat 没有在写入数据时,会复制一份作为临时数据库;
  2. 如果上一份临时数据库距今超过 5 分钟,则更新新的数据库作为临时数据库;
  3. 如果 start_record.bat 正在写入数据,为了防止复制未写入完成的数据库造成数据库不完整无法读取,会跳过更新新的数据库、继续使用上一次的数据库,这将会导致数据库的最新数据读取会有一些滞后性;
  4. 如果在没有临时数据库的情况下,使用 webui 时遇上了 start_record.bat 正在写入数据,webui 将没有数据库可以读取,这可能会产生 bug、致使需要在 start_record.bat 写入数据完毕后手动移除被错误创建的临时数据库,临时数据库才能被正确更新与读取;(常见于第一次读取新数据库时出现)

todo:
[] 完善在 webui 读取先前没有临时数据库、且 start_record.bat 正在写入数据库的情况下,可能出现的异常;

@Antonoko Antonoko added the bug Something isn't working label Nov 7, 2023
@Antonoko Antonoko added the P0 highest priority label Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P0 highest priority
Projects
None yet
Development

No branches or pull requests

2 participants