fix: a downloaded file with broken pixel data is skipped instead of ending the download run
CI and images / lint (push) Successful in 2s
CI and images / extension-version (push) Successful in 2s
CI and images / frontend-build (push) Successful in 24s
CI and images / extension-test (push) Successful in 19s
CI and images / backend-lint-and-test (push) Successful in 46s
CI and images / integration (push) Successful in 2m47s
CI and images / sign-extension (push) Successful in 2s
CI and images / build-agent (push) Successful in 4s
CI and images / build-web (push) Successful in 1m59s
CI and images / smoke-web (push) Successful in 49s
CI and images / promote (push) Successful in 1s
CI and images / refresh-dev (push) Skipped
CI and images / unattended-failure (push) Skipped
CI and images / lint (push) Successful in 2s
CI and images / extension-version (push) Successful in 2s
CI and images / frontend-build (push) Successful in 24s
CI and images / extension-test (push) Successful in 19s
CI and images / backend-lint-and-test (push) Successful in 46s
CI and images / integration (push) Successful in 2m47s
CI and images / sign-extension (push) Successful in 2s
CI and images / build-agent (push) Successful in 4s
CI and images / build-web (push) Successful in 1m59s
CI and images / smoke-web (push) Successful in 49s
CI and images / promote (push) Successful in 1s
CI and images / refresh-dev (push) Skipped
CI and images / unattended-failure (push) Skipped
Importer._import_media and Importer.attach_in_place each carried their own copy of the still-image filters (verify, minimum size, transparency, single colour) and of the phash step, and the copies had drifted: attach_in_place's transparency check had no guard for an OSError from decoding truncated pixel data, so that error escaped into DownloadService's per-file loop and ended the run with the remaining files unattached; its phash step swallowed every error and imported the broken file without a hash. Both paths now call _screen_still and _phash_of, which turn a decode error into an invalid_image skip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -216,6 +216,28 @@ def test_pil_load_oserror_in_transparency_check_skips_not_raises(
|
||||
assert "transparency check" in (result.error or "")
|
||||
|
||||
|
||||
def test_downloaded_file_with_broken_pixels_skips_not_raises(
|
||||
importer, import_layout, monkeypatch,
|
||||
):
|
||||
"""A downloaded file goes through the same filters as an imported one, so
|
||||
a decode error there is a skip; raised, it would end the download run
|
||||
before the rest of its files were attached."""
|
||||
_, images_root = import_layout
|
||||
path = images_root / "Bob" / "corrupt.png"
|
||||
_make_png_rgba(path, (100, 100), alpha=128)
|
||||
importer.settings.skip_transparent = True
|
||||
importer.settings.transparency_threshold = 0.5
|
||||
|
||||
def _boom(_self, _src):
|
||||
raise OSError("broken data stream when reading image file")
|
||||
monkeypatch.setattr(type(importer), "_transparency_pct", _boom)
|
||||
|
||||
result = importer.attach_in_place(path)
|
||||
assert result.status == "skipped"
|
||||
assert result.skip_reason == SkipReason.invalid_image
|
||||
assert "transparency check" in (result.error or "")
|
||||
|
||||
|
||||
def test_pil_load_oserror_in_phash_compute_skips_not_raises(
|
||||
importer, import_layout, monkeypatch,
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user