diff options
| author | 2026-03-23 03:25:44 +0000 | |
|---|---|---|
| committer | 2026-03-23 03:27:52 +0000 | |
| commit | 4a796e64ac576d6a3e3f2fe6174c4aa476ea0c5c (patch) | |
| tree | 44d72a20076ceab0981d0b553693d26ca36cc0be /refstore/files/transaction_dir_tree.go | |
| parent | receivepack: Lifecycle/ownership docs (diff) | |
| signature | No signature | |
refstore: Improve interfaces, errors, and make batch work v0.1.92
Diffstat (limited to 'refstore/files/transaction_dir_tree.go')
| -rw-r--r-- | refstore/files/transaction_dir_tree.go | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/refstore/files/transaction_dir_tree.go b/refstore/files/transaction_dir_tree.go deleted file mode 100644 index e317f604..00000000 --- a/refstore/files/transaction_dir_tree.go +++ /dev/null @@ -1,59 +0,0 @@ -package files - -import ( - "errors" - "fmt" - "os" - "path" -) - -func (tx *Transaction) removeEmptyDirTree(name refPath) error { - root := tx.store.rootFor(name.root) - - info, err := root.Stat(name.path) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - return nil - } - - return err - } - - if !info.IsDir() { - return nil - } - - return tx.removeEmptyDirTreeRecursive(name) -} - -func (tx *Transaction) removeEmptyDirTreeRecursive(name refPath) error { - root := tx.store.rootFor(name.root) - - dir, err := root.Open(name.path) - if err != nil { - return err - } - - entries, err := dir.ReadDir(-1) - _ = dir.Close() - - if err != nil { - return err - } - - for _, entry := range entries { - if !entry.IsDir() { - return fmt.Errorf("refstore/files: non-empty directory blocks reference %q", name.path) - } - - err = tx.removeEmptyDirTreeRecursive(refPath{ - root: name.root, - path: path.Join(name.path, entry.Name()), - }) - if err != nil { - return err - } - } - - return root.Remove(name.path) -} |
