mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-09-14 11:06:13 +05:00
Preserve interrupted 0.8.5 filesystem migrations
This commit is contained in:
parent
f67e2dc23c
commit
3980dff46d
@ -1127,7 +1127,7 @@ class Snapshot(ModelWithDeleteAfter, ModelWithOutputDir, ModelWithConfig, ModelW
|
||||
migration = migrations.get((current, next_ver))
|
||||
if migration is None:
|
||||
raise ValueError(f"No filesystem migration path from {current} to {next_ver}")
|
||||
cleanup = migration(source_dir=source_dir, config=runtime_config)
|
||||
cleanup = migration(source_dir=source_dir, config=runtime_config) or cleanup
|
||||
|
||||
current = next_ver
|
||||
source_dir = None
|
||||
@ -1329,7 +1329,7 @@ class Snapshot(ModelWithDeleteAfter, ModelWithOutputDir, ModelWithConfig, ModelW
|
||||
0.7.x/0.8.x: archive/{timestamp}
|
||||
0.9.x: archive/users/{username}/snapshots/YYYYMMDD/{domain}/{uuid}/
|
||||
"""
|
||||
if version in ("0.7.0", "0.8.0"):
|
||||
if version in ("0.7.0", "0.8.0", "0.8.5"):
|
||||
return CONSTANTS.ARCHIVE_DIR / self.timestamp
|
||||
|
||||
elif version in ("0.9.0", "0.9.1", "0.9.2", "0.9.3", "0.9.4", "1.0.0"):
|
||||
|
||||
@ -137,7 +137,19 @@ def test_update_migrates_every_declared_filesystem_version(tmp_path, initialized
|
||||
env = cli_env(disable_extractors=True)
|
||||
url = f"https://example.com/fs-{source_version}"
|
||||
legacy_layout = source_version.startswith(("0.7.", "0.8."))
|
||||
if legacy_layout:
|
||||
destination = None
|
||||
if source_version == "0.8.5":
|
||||
add_process = run_archivebox_cmd(["add", url], env=env, timeout=90)
|
||||
assert add_process.returncode == 0, add_process.stderr
|
||||
with use_archivebox_db(tmp_path):
|
||||
snapshot = Snapshot.objects.get(url=url)
|
||||
destination = snapshot.output_dir
|
||||
timestamp = snapshot.timestamp
|
||||
Snapshot.objects.filter(pk=snapshot.pk).update(fs_version=source_version)
|
||||
source_dir = tmp_path / "archive" / timestamp
|
||||
source_dir.mkdir(parents=True, exist_ok=True)
|
||||
(destination / "existing-user-output.bin").write_bytes(b"preserve interrupted migration output")
|
||||
elif legacy_layout:
|
||||
timestamp = "1700000000"
|
||||
source_dir = tmp_path / "archive" / timestamp
|
||||
source_dir.mkdir(parents=True, exist_ok=True)
|
||||
@ -172,7 +184,10 @@ def test_update_migrates_every_declared_filesystem_version(tmp_path, initialized
|
||||
with use_archivebox_db(tmp_path):
|
||||
snapshot = Snapshot.objects.get(url=url)
|
||||
assert snapshot.fs_version == Snapshot._fs_current_version()
|
||||
migrated_tree = filesystem_manifest(snapshot.output_dir.resolve())
|
||||
migrated_dir = snapshot.output_dir.resolve()
|
||||
migrated_tree = filesystem_manifest(migrated_dir)
|
||||
if source_version == "0.8.5":
|
||||
assert (migrated_dir / "existing-user-output.bin").read_bytes() == b"preserve interrupted migration output"
|
||||
|
||||
assert {path: migrated_tree.get(path) for path in original_tree} == original_tree
|
||||
if legacy_layout:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user