ITADN

[Code scan] Let LocalContext replace existing remote directories

#616Opennjzjz 创建于 2026-06-30
bug
N
njzjzcommented
Found by a Codex global repository scan of deepmodeling/dpdispatcher at commit 98a9e08. Problem `LocalContext._copy_from_local_to_remote()` removes an existing destination with `os.remove()` before copying, regardless of whether the existing destination is a directory. Relevant code https://github.com/deepmodeling/dpdispatcher/blob/98a9e081ea583a5811490e53ba2c4151d1d8b01d/dpdispatcher/contexts/local_context.py#L90-L105 Impact Uploading a directory in `forward_files` twice fails with `IsADirectoryError` when the remote destination already exists. Broken symlinks are also not handled consistently because `os.path.exists()` returns false for them. Suggested fix Use `os.path.lexists()` for destination checks. Remove directories with `shutil.rmtree()` unless the destination is a symlink, and remove files/symlinks with `os.remove()`.
0 条评论