| 622 | return dvc_fs.get_file(dvc_path, lpath, info=dvc_info, **kwargs) |
| 623 | |
| 624 | def du(self, path, total=True, maxdepth=None, withdirs=False, **kwargs): |
| 625 | if maxdepth is not None: |
| 626 | raise NotImplementedError |
| 627 | |
| 628 | sizes = {} |
| 629 | dus = {} |
| 630 | todo = deque([self.info(path)]) |
| 631 | while todo: |
| 632 | info = todo.popleft() |
| 633 | isdir = info["type"] == "directory" |
| 634 | size = info["size"] or 0 |
| 635 | name = info["name"] |
| 636 | |
| 637 | if not isdir: |
| 638 | sizes[name] = size |
| 639 | continue |
| 640 | |
| 641 | dvc_info = info.get("dvc_info") or {} |
| 642 | fs_info = info.get("fs_info") |
| 643 | entry = dvc_info.get("entry") |
| 644 | if ( |
| 645 | dvc_info |
| 646 | and not fs_info |
| 647 | and entry is not None |
| 648 | and entry.size is not None |
| 649 | ): |
| 650 | dus[name] = entry.size |
| 651 | continue |
| 652 | |
| 653 | if withdirs: |
| 654 | sizes[name] = size |
| 655 | |
| 656 | todo.extend(self.ls(info["name"], detail=True)) |
| 657 | |
| 658 | if total: |
| 659 | return sum(sizes.values()) + sum(dus.values()) |
| 660 | |
| 661 | return sizes |
| 662 | |
| 663 | def close(self): |
| 664 | self._repo_stack.close() |