Skip to content

Commit

Permalink
fix: force_size should not skip subsequent sizes (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
iowk committed Sep 24, 2024
1 parent 6e9c6c6 commit 6c99da3
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/icloudpd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
64 changes: 64 additions & 0 deletions tests/test_download_photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down

0 comments on commit 6c99da3

Please sign in to comment.