File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -144,7 +144,20 @@ def remove_if_exists(filepath):
144144
145145
146146def fetch_and_rename (fetchurl : str , target_file : str , new_name : str ) -> None :
147+ # Fetch into a temporary filename (new_name) and only replace the
148+ # real target if content actually changed. This avoids touching
149+ # mtimes when the fetched content is identical and prevents
150+ # unnecessary Sphinx rebuilds.
147151 fetch_url (fetchurl , fpath = new_name , verbose = False )
152+
153+ try :
154+ # If target exists and is identical, remove fetched temp and skip replace
155+ if os .path .exists (target_file ) and filecmp .cmp (new_name , target_file , shallow = False ):
156+ debug (f"No change for { target_file } (fetched content identical)" )
157+ os .remove (new_name )
158+ return
159+ except OSError as e :
160+ debug (f"Failed to compare fetched file and target: { e } " )
148161 progress (f"Renaming { new_name } to { target_file } " )
149162 os .replace (new_name , target_file )
150163
You can’t perform that action at this time.
0 commit comments