mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-22 06:22:16 +00:00
sync, check disk space
This commit is contained in:
@@ -5,7 +5,7 @@ from pathlib import Path
|
||||
|
||||
import click
|
||||
|
||||
from http_host_lib.utils import download_file_aria2
|
||||
from http_host_lib.utils import download_file_aria2, get_remote_file_size
|
||||
|
||||
|
||||
def download_and_extract_tileset(area: str, version: str, runs_dir: Path) -> bool:
|
||||
@@ -26,6 +26,17 @@ def download_and_extract_tileset(area: str, version: str, runs_dir: Path) -> boo
|
||||
temp_dir.mkdir(parents=True)
|
||||
|
||||
url = f'https://{area}.openfreemap.com/{version}/tiles.btrfs.gz'
|
||||
|
||||
# check disk space
|
||||
disk_free = shutil.disk_usage(temp_dir).free
|
||||
file_size = get_remote_file_size(url)
|
||||
if not file_size:
|
||||
raise ValueError('Cannot get remote file size')
|
||||
|
||||
needed_space = file_size * 3
|
||||
if disk_free < needed_space:
|
||||
raise ValueError(f'Not enough disk space. Needed: {needed_space}, free space: {disk_free}')
|
||||
|
||||
target_file = temp_dir / 'tiles.btrfs.gz'
|
||||
download_file_aria2(url, target_file)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user