mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
export: Remove export-most-recent symlink.
The only callsite of do_export_realm calls `rmtree` on the output path, which means this symlink is always dangling. Since realms can also be exported by end-users, following it would always be a race condition, anyways. Remove it.
This commit is contained in:
committed by
Tim Abbott
parent
6a8deb7115
commit
cf33119348
@@ -16,7 +16,6 @@ import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
from collections.abc import Callable, Iterable, Mapping
|
||||
from contextlib import suppress
|
||||
from datetime import datetime
|
||||
from email.headerregistry import Address
|
||||
from functools import cache
|
||||
@@ -35,7 +34,6 @@ from psycopg2 import sql
|
||||
|
||||
import zerver.lib.upload
|
||||
from analytics.models import RealmCount, StreamCount, UserCount
|
||||
from scripts.lib.zulip_tools import overwrite_symlink
|
||||
from version import ZULIP_VERSION
|
||||
from zerver.lib.avatar_hash import user_avatar_base_path_from_ids
|
||||
from zerver.lib.migration_status import MigrationStatusJson, parse_migration_status
|
||||
@@ -2411,8 +2409,6 @@ def do_export_realm(
|
||||
|
||||
realm_config = get_realm_config()
|
||||
|
||||
create_soft_link(source=output_dir, in_progress=True)
|
||||
|
||||
exportable_scheduled_message_ids = get_exportable_scheduled_message_ids(
|
||||
realm, export_type, exportable_user_ids
|
||||
)
|
||||
@@ -2500,7 +2496,6 @@ def do_export_realm(
|
||||
do_common_export_processes(output_dir)
|
||||
|
||||
logging.info("Finished exporting %s", realm.string_id)
|
||||
create_soft_link(source=output_dir, in_progress=False)
|
||||
|
||||
stats = do_write_stats_file_for_realm_export(output_dir)
|
||||
|
||||
@@ -2532,27 +2527,6 @@ def export_attachment_table(
|
||||
return attachments
|
||||
|
||||
|
||||
def create_soft_link(source: Path, in_progress: bool = True) -> None:
|
||||
is_done = not in_progress
|
||||
if settings.DEVELOPMENT:
|
||||
in_progress_link = os.path.join(settings.DEPLOY_ROOT, "var", "export-in-progress")
|
||||
done_link = os.path.join(settings.DEPLOY_ROOT, "var", "export-most-recent")
|
||||
else:
|
||||
in_progress_link = "/home/zulip/export-in-progress"
|
||||
done_link = "/home/zulip/export-most-recent"
|
||||
|
||||
if in_progress:
|
||||
new_target = in_progress_link
|
||||
else:
|
||||
with suppress(FileNotFoundError):
|
||||
os.remove(in_progress_link)
|
||||
new_target = done_link
|
||||
|
||||
overwrite_symlink(source, new_target)
|
||||
if is_done:
|
||||
logging.info("See %s for output files", new_target)
|
||||
|
||||
|
||||
def launch_user_message_subprocesses(
|
||||
threads: int,
|
||||
output_dir: Path,
|
||||
|
@@ -412,7 +412,7 @@ class RealmImportExportTest(ExportFile):
|
||||
if export_type == RealmExport.EXPORT_FULL_WITH_CONSENT:
|
||||
assert exportable_user_ids is not None
|
||||
|
||||
with patch("zerver.lib.export.create_soft_link"), self.assertLogs(level="INFO"):
|
||||
with self.assertLogs(level="INFO"):
|
||||
do_export_realm(
|
||||
realm=realm,
|
||||
output_dir=output_dir,
|
||||
|
Reference in New Issue
Block a user