Skip to content

Commit da3781f

Browse files
retry on transfer errors (#1203)
1 parent 0f218ba commit da3781f

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ node_modules/
2323
/package.json
2424
/package-lock.json
2525
# used for local troubleshooting
26-
.photos
26+
.photos
27+
.cookies/

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- fix: transfer chunk issues terminate with error [#1202](https://github.com/icloud-photos-downloader/icloud_photos_downloader/issues/1202)
6+
57
## 1.29.2 (2025-07-21)
68

79
- fix: emulating old browser and client version fails authentication [#1073](https://github.com/icloud-photos-downloader/icloud_photos_downloader/issues/1073)

src/icloudpd/base.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
from multiprocessing import freeze_support
55

66
from requests import Timeout
7-
from requests.exceptions import ConnectionError
7+
from requests.exceptions import (
8+
ChunkedEncodingError,
9+
ConnectionError,
10+
ContentDecodingError,
11+
StreamConsumedError,
12+
UnrewindableBodyError,
13+
)
814
from urllib3.exceptions import NewConnectionError
915

1016
import foundation
@@ -1311,7 +1317,7 @@ def core(
13111317
skip_bar = not os.environ.get("FORCE_TQDM") and (
13121318
only_print_filenames or no_progress_bar or not sys.stdout.isatty()
13131319
)
1314-
while True: # watch with interval
1320+
while True: # watch with interval & retry
13151321
try:
13161322
icloud = authenticator(
13171323
logger,
@@ -1542,6 +1548,16 @@ def should_break(counter: Counter) -> bool:
15421548
return 1
15431549
else:
15441550
pass
1551+
except (
1552+
ChunkedEncodingError,
1553+
ContentDecodingError,
1554+
StreamConsumedError,
1555+
UnrewindableBodyError,
1556+
) as error:
1557+
logger.debug(error)
1558+
logger.debug("Retrying...")
1559+
# these errors we can safely retry
1560+
continue
15451561
if watch_interval: # pragma: no cover
15461562
logger.info(f"Waiting for {watch_interval} sec...")
15471563
interval: Sequence[int] = range(1, watch_interval)

0 commit comments

Comments
 (0)