Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backup): handle non-feature-layer items #22

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions jobs/src/backup/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import json
import tempfile
from datetime import datetime, timezone
from os import getenv
from pathlib import Path
from pprint import pprint

import arcgis
Expand Down Expand Up @@ -93,6 +95,10 @@ def backup():
print(
f"Failed to export and download {export_item.title} ({export_item.id}), {export_item.status()}"
)
else:
#: create empty zip file in a temporary directory
download_path = Path(tempfile.gettempdir()) / zip_filename
download_path.touch()

item_json = dict(item)
add_to_zip(
Expand All @@ -101,6 +107,9 @@ def backup():

write_to_bucket(item.id, zip_filename, download_path, NEEDS_WEEKLY_BACKUP)

#: cleanup
Path(download_path).unlink()

summary[item.id] = write_to_firestore(item.id, item.title, datetime.now(timezone.utc).isoformat())

has_more = response["nextStart"] > 0
Expand Down
3 changes: 0 additions & 3 deletions jobs/src/backup/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ def write_to_bucket(item_id, filename, path, needs_weekly_backup):
blob = bucket.blob(category_path)
blob.upload_from_filename(path)

#: cleanup
Path(path).unlink()


def get_versions(item_id):
bucket_name = get_secrets()["BUCKET_NAME"]
Expand Down