mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 14:02:15 +00:00
upload_manager
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
import click
|
||||
@@ -35,6 +36,72 @@ def upload_rclone(area, run):
|
||||
)
|
||||
|
||||
|
||||
def make_indexes():
|
||||
for area in AREAS:
|
||||
print(f'creating index {area}')
|
||||
|
||||
# files
|
||||
p = subprocess.run(
|
||||
[
|
||||
'rclone',
|
||||
'lsf',
|
||||
'-R',
|
||||
'--files-only',
|
||||
'--fast-list',
|
||||
'--exclude',
|
||||
'dirs.txt',
|
||||
'--exclude',
|
||||
'index.txt',
|
||||
f'remote:ofm-{area}',
|
||||
],
|
||||
env=dict(RCLONE_CONFIG='/data/ofm/config/rclone.conf'),
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
index_str = p.stdout
|
||||
|
||||
subprocess.run(
|
||||
[
|
||||
'rclone',
|
||||
'rcat',
|
||||
f'remote:ofm-{area}/index.txt',
|
||||
],
|
||||
env=dict(RCLONE_CONFIG='/data/ofm/config/rclone.conf'),
|
||||
check=True,
|
||||
input=index_str.encode(),
|
||||
)
|
||||
|
||||
# directories
|
||||
p = subprocess.run(
|
||||
[
|
||||
'rclone',
|
||||
'lsf',
|
||||
'-R',
|
||||
'--dirs-only',
|
||||
'--dir-slash=false',
|
||||
'--fast-list',
|
||||
f'remote:ofm-{area}',
|
||||
],
|
||||
env=dict(RCLONE_CONFIG='/data/ofm/config/rclone.conf'),
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
index_str = p.stdout
|
||||
|
||||
subprocess.run(
|
||||
[
|
||||
'rclone',
|
||||
'rcat',
|
||||
f'remote:ofm-{area}/dirs.txt',
|
||||
],
|
||||
env=dict(RCLONE_CONFIG='/data/ofm/config/rclone.conf'),
|
||||
check=True,
|
||||
input=index_str.encode(),
|
||||
)
|
||||
|
||||
|
||||
@click.group()
|
||||
def cli():
|
||||
"""
|
||||
@@ -76,6 +143,17 @@ def upload_runs():
|
||||
print(f'uploading {area} {run}')
|
||||
upload_rclone(area, run)
|
||||
|
||||
make_indexes()
|
||||
|
||||
|
||||
@cli.command()
|
||||
def index():
|
||||
"""
|
||||
Run index on Cloudflare buckets
|
||||
"""
|
||||
|
||||
make_indexes()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli()
|
||||
|
||||
Reference in New Issue
Block a user