mirror of
https://github.com/zulip/zulip.git
synced 2025-11-18 21:28:44 +00:00
export.py: Add 'delete after upload' option for removing tarball.
This allows removal of the local tarball upon a succesful s3 upload. A part of the public-only-realm-export webapp feature.
This commit is contained in:
@@ -1597,8 +1597,10 @@ def get_analytics_config() -> Config:
|
||||
|
||||
return analytics_config
|
||||
|
||||
def export_realm_wrapper(realm: Realm, output_dir: str, threads: int,
|
||||
upload_to_s3: bool, public_only: bool) -> None:
|
||||
|
||||
def export_realm_wrapper(realm: Realm, output_dir: str,
|
||||
threads: int, upload_to_s3: bool,
|
||||
public_only: bool, delete_after_upload: bool) -> None:
|
||||
do_export_realm(realm=realm, output_dir=output_dir, threads=threads, public_only=public_only)
|
||||
print("Finished exporting to %s; tarring" % (output_dir,))
|
||||
|
||||
@@ -1634,3 +1636,7 @@ def export_realm_wrapper(realm: Realm, output_dir: str, threads: int,
|
||||
bucket=bucket.name,
|
||||
key=key.key)
|
||||
print("Uploaded to %s" % (public_url,))
|
||||
|
||||
if delete_after_upload:
|
||||
os.remove(tarball_path)
|
||||
print("Successfully deleted the tarball at %s" % (tarball_path,))
|
||||
|
||||
@@ -95,6 +95,9 @@ class Command(ZulipBaseCommand):
|
||||
parser.add_argument('--upload-to-s3',
|
||||
action="store_true",
|
||||
help="Whether to upload resulting tarball to s3")
|
||||
parser.add_argument('--delete-after-upload',
|
||||
action="store_true",
|
||||
help='Automatically delete the local tarball after a successful export')
|
||||
self.add_realm_args(parser, True)
|
||||
|
||||
def handle(self, *args: Any, **options: Any) -> None:
|
||||
@@ -117,4 +120,5 @@ class Command(ZulipBaseCommand):
|
||||
# Allows us to trigger exports separately from command line argument parsing
|
||||
export_realm_wrapper(realm=realm, output_dir=output_dir,
|
||||
threads=num_threads, upload_to_s3=options['upload_to_s3'],
|
||||
public_only=options["public_only"])
|
||||
public_only=options["public_only"],
|
||||
delete_after_upload=options["delete_after_upload"])
|
||||
|
||||
Reference in New Issue
Block a user