Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: force_size should not skip subsequent sizes #956

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
"[email protected]",
"--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
Loading