diff --git a/opf/_common/checkpoint_download.py b/opf/_common/checkpoint_download.py index 743f889..4d1c6f5 100644 --- a/opf/_common/checkpoint_download.py +++ b/opf/_common/checkpoint_download.py @@ -76,13 +76,16 @@ def _promote_original_subtree(target: Path) -> None: f"Downloaded checkpoint is missing expected subtree: {original_dir}" ) - for path in original_dir.iterdir(): + entries = list(original_dir.iterdir()) + for path in entries: destination = target / path.name if destination.exists(): raise RuntimeError( "Cannot promote downloaded checkpoint file because destination " f"already exists: {destination}" ) + for path in entries: + destination = target / path.name shutil.move(str(path), str(destination)) original_dir.rmdir()