diff --git a/archivebox/core/models.py b/archivebox/core/models.py index 84506d16..8e18e115 100644 --- a/archivebox/core/models.py +++ b/archivebox/core/models.py @@ -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"): diff --git a/archivebox/tests/test_cli_update_reindex_snapshots.py b/archivebox/tests/test_cli_update_reindex_snapshots.py index f3393b5a..9057c1d2 100644 --- a/archivebox/tests/test_cli_update_reindex_snapshots.py +++ b/archivebox/tests/test_cli_update_reindex_snapshots.py @@ -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: