MCPcopy Create free account
hub / github.com/deepseek-ai/3FS / remove

Method remove

hf3fs_utils/fs.py:200–220  ·  view source on GitHub ↗
(self, path: str, recursive: bool)

Source from the content-addressed store, hash-verified

198 self._ioctl(old_dir_fd, cmd, buffer)
199
200 def remove(self, path: str, recursive: bool) -> None:
201 dir_fd = None
202 try:
203 dir_fd, dir_st, filename = self.split_path(path)
204 st = os.stat(filename, dir_fd=dir_fd, follow_symlinks=False)
205 if stat.S_ISLNK(st.st_mode):
206 raise RuntimeError(f"{path} is symlink")
207 if stat.S_ISDIR(st.st_mode) and recursive:
208 # The user must be the owner of the directory and have rwx permissions
209 imode = stat.S_IMODE(st.st_mode)
210 if st.st_uid != os.geteuid() or (imode & 0o700) != 0o700:
211 raise PermissionError(errno.EPERM, os.strerror(errno.EPERM), path)
212
213 try:
214 self._remove_ioctl(dir_fd, dir_st.st_ino, filename, recursive)
215 except OSError as ex:
216 ex.filename = path
217 raise ex
218 finally:
219 if dir_fd is not None:
220 os.close(dir_fd)
221
222 def _remove_ioctl(
223 self, parent_fd: int, parent_ino: int, filename: str, recursive: bool

Callers 1

rmtreeFunction · 0.45

Calls 4

split_pathMethod · 0.95
_remove_ioctlMethod · 0.95
statMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected