Skip to content

Commit

Permalink
add wipe command
Browse files Browse the repository at this point in the history
  • Loading branch information
FynnBe committed Feb 22, 2024
1 parent 8414b4c commit 3b3e632
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions backoffice/_backoffice.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ def __init__(
super().__init__()
self.client = Client(host=host, bucket=bucket, prefix=prefix)

def wipe(self, subfolder: str = ""):
"""DANGER ZONE: wipes `subfolder` completely, only use for test folders!"""
url = self.client.get_file_url(subfolder)
key_parts = ("sandbox", "testing")
if not all(p in url for p in key_parts):
raise RuntimeError(f"Refusing to wipe {url} (missing {key_parts})")

self.client.rm_dir(subfolder)

def stage(self, resource_id: str, package_url: str):
resource = RemoteResource(client=Client(), id=resource_id)
staged = resource.stage_new_version(package_url)
Expand Down Expand Up @@ -55,5 +64,5 @@ def publish(self, resource_id: str, stage_nr: int):
published = staged.publish()
assert isinstance(published, PublishedVersion)

def backup(self, destination: str = os.environ["ZENODO_URL"]):
_ = backup(self.client, destination)
def backup(self, destination: Optional[str] = None):
_ = backup(self.client, destination or os.environ["ZENODO_URL"])

0 comments on commit 3b3e632

Please sign in to comment.