You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defclean_path(path: Path) ->None:
forfinpath.glob("*"):
iff.chmodinos.supports_follow_symlinks:
f.chmod(0o700, follow_symlinks=False)
elifnotf.is_symlink():
# Linux does not support setting permissions on symlinks.# Permissions of symlinks are never used in that OS.f.chmod(0o700)
iff.is_symlink() orf.is_file():
f.unlink()
eliff.is_dir():
clean_path(f)
f.rmdir()
Test:
deftest_folder_cleanup_with_symlinks(tmp_path):
# Create the target directorytarget=tmp_path/"test"target.mkdir(parents=True)
# Create the directories for symlinkssymlinked_dir=tmp_path/"non_target_dir"symlinked_dir.mkdir(parents=True)
symlinked_file=tmp_path/"non_target_file"symlinked_file.touch()
# Create symlinks in the target directorytarget_symlink_dir=target/"symlinked_dir"os.symlink(symlinked_dir, target_symlink_dir)
target_symlink_file=target/"symlinked_file"os.symlink(symlinked_file, target_symlink_file)
clean_path(path=target)
# Ensure the symlinks got claned but the target still existsassertnottarget_symlink_dir.exists(), "Symlink to directory did not get cleaned!"assertnottarget_symlink_file.exists(), "Symlink to file did not get cleaned!"assertsymlinked_dir.exists(), "Symlinked directory got cleaned!"assertsymlinked_file.exists(), "Symlinked file got cleaned!"
rse-sagemaker-shim/sagemaker_shim/models.py
Lines 145 to 153 in 25fd14a
By default, the chmod follows symlinks. This goes wrong if the targetable symlink no longer exists.
The text was updated successfully, but these errors were encountered: