Browse Source

检查资源异步下载

zhangyh 9 months ago
parent
commit
584b635b9d
1 changed files with 7 additions and 3 deletions
  1. 7 3
      python/service/init_load_source.py

+ 7 - 3
python/service/init_load_source.py

@@ -15,13 +15,17 @@ class init_load_source:
     async def down_resouce(self):
         response_data = await self.get_update_file()
         if response_data:
-            for relative_file_path, value in response_data.items():
+            for relative_file_path, value in response_data['data'].items():
                 file_path = f"{os.getcwd()}/{relative_file_path}"
                 if os.path.exists(file_path):
                     file_md5 = get_md5(file_path)
                     if file_md5 != value["file_md5"]:
-                        print(f"md5 不同 开始下载:{file_path}")
-                        await self.async_download_file(value["url"], file_path)
+                        file_modified_time = get_modified_time(file_path)
+                        if compare_two_times(file_modified_time, response_data["update_time"]) == "left_new":
+                            continue
+                        else:
+                            print(f"md5 不同 开始下载:{file_path}")
+                            await self.async_download_file(value["url"], file_path)
                     else:
                         pass
                 else: