mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 14:02:15 +00:00
refactor, auto_clean
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user