refactor, auto_clean

This commit is contained in:
Zsolt Ero
2024-08-30 02:16:40 +02:00
parent d753c8738a
commit a7daec032e
10 changed files with 145 additions and 82 deletions

View File

@@ -1,16 +1,13 @@
import sys
from pathlib import Path
import requests
from http_host_lib.config import config
from http_host_lib.utils import assert_linux, assert_sudo
def sync_version_files() -> bool:
def fetch_version_files() -> bool:
"""
Syncs the version files from remote to local.
Remove versions are specified by https://assets.openfreemap.com/versions/deployed_{area}.txt
Remote versions are specified by https://assets.openfreemap.com/versions/deployed_{area}.txt
"""
print('Syncing local version files')
@@ -18,9 +15,6 @@ def sync_version_files() -> bool:
assert_linux()
assert_sudo()
if not config.mnt_dir.exists():
sys.exit(' mount needs to be run first')
need_nginx_sync = False
for area in config.areas:
@@ -37,15 +31,8 @@ def sync_version_files() -> bool:
except Exception:
local_version_old = None
mnt_file = Path(f'/mnt/ofm/{area}-{remote_version}/metadata.json')
if not mnt_file.exists():
print(' local version does not exist')
if local_version_old is not None:
local_version_file.unlink()
need_nginx_sync = True
continue
if remote_version != local_version_old:
config.deployed_versions_dir.mkdir(exist_ok=True, parents=True)
local_version_file.write_text(remote_version)
need_nginx_sync = True