File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed
Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -1233,6 +1233,8 @@ def session_error_handle_builder(
12331233) -> None :
12341234 """Handles session errors in the PhotoAlbum photos iterator"""
12351235 if "Invalid global session" in str (ex ):
1236+ if constants .MAX_RETRIES == 0 :
1237+ logger .error ("Session error, re-authenticating..." )
12361238 if attempt > constants .MAX_RETRIES :
12371239 logger .error ("iCloud re-authentication failed. Please try again later." )
12381240 raise ex
Original file line number Diff line number Diff line change 33from typing import Final
44
55# For retrying connection after timeouts and errors
6- MAX_RETRIES : Final [int ] = 4
6+ MAX_RETRIES : Final [int ] = 0
77WAIT_SECONDS : Final [int ] = 5
Original file line number Diff line number Diff line change @@ -112,7 +112,8 @@ def download_media(
112112 if not mkdirs_local (logger , download_path ):
113113 return False
114114
115- for retries in range (constants .MAX_RETRIES ):
115+ retries = 0
116+ while True :
116117 try :
117118 photo_response = photo .download (version .url )
118119 if photo_response :
@@ -134,6 +135,9 @@ def download_media(
134135
135136 icloud .authenticate ()
136137 else :
138+ # short circuiting 0 retries
139+ if retries == constants .MAX_RETRIES :
140+ break
137141 # you end up here when p.e. throttling by Apple happens
138142 wait_time = (retries + 1 ) * constants .WAIT_SECONDS
139143 logger .error (
@@ -150,7 +154,10 @@ def download_media(
150154 download_path ,
151155 )
152156 break
153- else :
157+ retries = retries + 1
158+ if retries >= constants .MAX_RETRIES :
159+ break
160+ if retries >= constants .MAX_RETRIES :
154161 logger .error (
155162 "Could not download %s. Please try again later." ,
156163 photo .filename ,
You can’t perform that action at this time.
0 commit comments