diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c276602d..309703f46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- fix: force_size should not skip subsequent sizes [ref](https://github.com/icloud-photos-downloader/icloud_photos_downloader/issues/955) + ## 1.23.4 (2024-09-02) - fix: support plain text encoding for filename in addition to base64 [ref](https://github.com/boredazfcuk/docker-icloudpd/issues/641) diff --git a/src/icloudpd/base.py b/src/icloudpd/base.py index 30f9f71ac..96620fc74 100644 --- a/src/icloudpd/base.py +++ b/src/icloudpd/base.py @@ -893,7 +893,7 @@ def download_photo_(counter: Counter, photo: PhotoAsset) -> bool: download_size.value, photo.filename, ) - return False + continue if AssetVersionSize.ORIGINAL in size: continue # that should avoid double download for original download_size = AssetVersionSize.ORIGINAL diff --git a/tests/test_download_photos.py b/tests/test_download_photos.py index 44851d345..ded3cf4b3 100644 --- a/tests/test_download_photos.py +++ b/tests/test_download_photos.py @@ -825,6 +825,70 @@ def test_force_size(self) -> None: assert result.exit_code == 0 + def test_download_two_sizes_with_force_size(self) -> None: + base_dir = os.path.join(self.fixtures_path, inspect.stack()[0][3]) + with mock.patch("icloudpd.download.download_media") as dp_patched: + dp_patched.return_value = True + + with mock.patch("icloudpd.download.os.utime") as ut_patched: + ut_patched.return_value = None + + with mock.patch.object(PhotoAsset, "versions", new_callable=PropertyMock) as pa: + pa.return_value = { + AssetVersionSize.ORIGINAL: AssetVersion("IMG_7409.JPG", 1, "http", "jpeg"), + AssetVersionSize.THUMB: AssetVersion("IMG_7409.JPG", 1, "http", "jpeg"), + } + + data_dir, result = run_icloudpd_test( + self.assertEqual, + self.vcr_path, + base_dir, + "listing_photos.yml", + [], + [], + [ + "--username", + "jdoe@gmail.com", + "--password", + "password1", + "--recent", + "1", + "--size", + "medium", + "--size", + "thumb", + "--force-size", + "--no-progress-bar", + "--threads-num", + "1", + ], + ) + + self.assertIn( + "DEBUG Looking up all photos and videos from album All Photos...", + self._caplog.text, + ) + self.assertIn( + f"INFO Downloading the first medium,thumb photo or video to {data_dir} ...", + self._caplog.text, + ) + self.assertIn( + "ERROR medium size does not exist for IMG_7409.JPG. Skipping...", + self._caplog.text, + ) + self.assertIn("INFO All photos have been downloaded", self._caplog.text) + dp_patched.assert_called_once_with( + ANY, + False, + ANY, + ANY, + f"{os.path.join(data_dir, os.path.normpath('2018/07/31/IMG_7409.JPG'))}", + ANY, + AssetVersionSize.THUMB, + ) + + assert result.exit_code == 0 + def test_invalid_creation_date(self) -> None: base_dir = os.path.join(self.fixtures_path, inspect.stack()[0][3])