(self, path, st, status=None, hardlinkable=True, strip_prefix=None)
| 1273 | |
| 1274 | @contextmanager |
| 1275 | def create_helper(self, path, st, status=None, hardlinkable=True, strip_prefix=None): |
| 1276 | if strip_prefix is not None: |
| 1277 | assert not path.endswith("/") |
| 1278 | if strip_prefix.startswith(path + "/"): |
| 1279 | # still on a directory level that shall be stripped - do not create an item for this! |
| 1280 | yield None, "x", False, None |
| 1281 | return |
| 1282 | # adjust path, remove stripped directory levels |
| 1283 | path = path.removeprefix(strip_prefix) |
| 1284 | |
| 1285 | sanitized_path = remove_dotdot_prefixes(path) |
| 1286 | item = Item(path=sanitized_path) |
| 1287 | hardlinked = hardlinkable and st.st_nlink > 1 |
| 1288 | hl_chunks = None |
| 1289 | update_map = False |
| 1290 | if hardlinked: |
| 1291 | status = "h" # hard link |
| 1292 | nothing = object() |
| 1293 | chunks = self.hlm.retrieve(id=(st.st_ino, st.st_dev), default=nothing) |
| 1294 | if chunks is nothing: |
| 1295 | update_map = True |
| 1296 | elif chunks is not None: |
| 1297 | hl_chunks = chunks |
| 1298 | item.hlid = self.hlm.hardlink_id_from_inode(ino=st.st_ino, dev=st.st_dev) |
| 1299 | yield item, status, hardlinked, hl_chunks |
| 1300 | maybe_exclude_by_attr(item) |
| 1301 | self.add_item(item, stats=self.stats) |
| 1302 | if update_map: |
| 1303 | # remember the hlid of this fs object and if the item has chunks, |
| 1304 | # also remember them, so we do not have to re-chunk a hard link. |
| 1305 | chunks = item.chunks if "chunks" in item else None |
| 1306 | self.hlm.remember(id=(st.st_ino, st.st_dev), info=chunks) |
| 1307 | |
| 1308 | def process_dir_with_fd(self, *, path, fd, st, strip_prefix): |
| 1309 | with self.create_helper(path, st, "d", hardlinkable=False, strip_prefix=strip_prefix) as ( |
no test coverage detected