Compare commits

..

3 commits
v1.1.7 ... main

Author SHA1 Message Date
673b30c7be update fix
All checks were successful
Build and Publish Release / Build Linux (release) Successful in 2m11s
Build and Publish Release / Build Windows (release) Successful in 4m49s
Build and Publish Release / Upload Assets to Release (release) Successful in 11s
2026-05-05 15:20:16 +05:00
b07ebd68ab microfix 2026-05-05 15:15:29 +05:00
0c47d8c0a9 action update
All checks were successful
Build and Publish Release / Build Windows (release) Successful in 5m25s
Build and Publish Release / Build Linux (release) Successful in 18m56s
Build and Publish Release / Upload Assets to Release (release) Successful in 11s
2026-05-04 19:18:42 +05:00
2 changed files with 61 additions and 20 deletions

View file

@ -66,7 +66,7 @@ jobs:
name: Upload Assets to Release
needs: [build-linux, build-windows]
runs-on: ubuntu-latest
if: always()
if: always() && (needs.build-linux.result == 'success' || needs.build-windows.result == 'success')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3

79
main.py
View file

@ -11,11 +11,31 @@ import threading
import subprocess
import re
APP_VERSION = "v1.1.6"
UPDATE_API_URL = "https://git.borderban.ru/api/v1/repos/BorderBan/client-py/releases/latest"
SERVER_URL = "https://server1.borderban.ru/mods/"
CONFIG_FILE = Path.home() / ".factorio_sync_config.json"
def load_app_config():
if CONFIG_FILE.exists():
try:
return json.loads(CONFIG_FILE.read_text())
except Exception:
pass
return {}
def save_app_config(new_data):
config = load_app_config()
config.update(new_data)
try:
CONFIG_FILE.write_text(json.dumps(config))
except Exception as e:
print(f"Ошибка сохранения конфига: {e}")
if not getattr(sys, 'frozen', False):
APP_VERSION = "Dev"
else:
APP_VERSION = load_app_config().get("app_version", "Неизвестная версия")
def get_mod_base_name(filename):
# Пытаемся отсечь версию мода (обычно ИмяМода_1.0.0.zip)
match = re.match(r"^(.+)_(\d+\.\d+\.\d+)\.zip$", filename)
@ -62,12 +82,10 @@ def check_and_update(root):
release_data = response.json()
latest_version = release_data.get("tag_name")
# Проверяем, нужна ли загрузка
if not latest_version or latest_version == APP_VERSION:
if not latest_version:
update_win.destroy()
return
# Определяем имя нужного ассета в зависимости от ОС
system = platform.system().lower()
asset_name = None
if system == "windows":
@ -79,12 +97,34 @@ def check_and_update(root):
update_win.destroy()
return
download_url = next((asset.get("browser_download_url") for asset in release_data.get("assets", []) if asset.get("name") == asset_name), None)
target_asset = next((asset for asset in release_data.get("assets", []) if asset.get("name") == asset_name), None)
if not target_asset:
update_win.destroy()
return
download_url = target_asset.get("browser_download_url")
if not download_url:
update_win.destroy()
return
remote_size = target_asset.get("size", 0)
local_size = os.path.getsize(exe_path)
# Если размер файла совпадает с размером из релиза, считаем, что мы уже на этой версии
if remote_size and local_size == remote_size:
if load_app_config().get("app_version") != latest_version:
save_app_config({"app_version": latest_version})
global APP_VERSION
APP_VERSION = latest_version
update_win.destroy()
return
# На крайний случай проверяем сохраненную версию, если размер не удалось получить
if not remote_size and load_app_config().get("app_version") == latest_version:
update_win.destroy()
return
# Обновляем текст на окне, если обновление найдено
update_label.config(text=f"Обнаружена новая версия ({latest_version}).\nЗагрузка обновления...\nПожалуйста, подождите.")
update_win.update()
@ -104,6 +144,9 @@ def check_and_update(root):
os.replace(exe_path, old_exe_path)
os.replace(new_exe_path, exe_path)
# Сохраняем новую версию в конфиг перед перезапуском
save_app_config({"app_version": latest_version})
# Перезапускаем новую версию и выходим из текущей
subprocess.Popen([exe_path] + sys.argv[1:])
sys.exit(0)
@ -119,25 +162,23 @@ class SyncApp:
self.root.title(f"Factorio Mod Sync {APP_VERSION}")
self.root.geometry("500x350")
self.config = self.load_config()
self.config = load_app_config()
if "mods_path" not in self.config:
self.config["mods_path"] = ""
if "game_path" not in self.config:
self.config["game_path"] = ""
self.setup_ui()
def load_config(self):
if CONFIG_FILE.exists():
data = json.loads(CONFIG_FILE.read_text())
return {
"mods_path": data.get("mods_path", ""),
"game_path": data.get("game_path", "")
}
return {"mods_path": "", "game_path": ""}
def save_config(self, mods_path=None, game_path=None):
config = self.load_config()
data_to_save = {}
if mods_path is not None:
config["mods_path"] = mods_path
data_to_save["mods_path"] = mods_path
self.config["mods_path"] = mods_path
if game_path is not None:
config["game_path"] = game_path
CONFIG_FILE.write_text(json.dumps(config))
data_to_save["game_path"] = game_path
self.config["game_path"] = game_path
save_app_config(data_to_save)
def setup_ui(self):
# Выбор пути