Skip to content

Commit

Permalink
fix: delete should be recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
ALX99 committed May 19, 2024
1 parent f124af9 commit e5ef128
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions internal/models/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

type fsys interface {
ReadDir(path string) ([]fs.DirEntry, error)
Remove(path string) error
RemoveAll(path string) error
}

var osi fsys = realOS{}
Expand All @@ -18,6 +18,6 @@ func (realOS) ReadDir(path string) ([]fs.DirEntry, error) {
return os.ReadDir(path)
}

func (realOS) Remove(path string) error {
return os.Remove(path)
func (realOS) RemoveAll(path string) error {
return os.RemoveAll(path)
}
2 changes: 1 addition & 1 deletion internal/models/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (m mockOS) ReadDir(path string) ([]fs.DirEntry, error) {
return nil, os.ErrNotExist
}

func (m mockOS) Remove(fPath string) error {
func (m mockOS) RemoveAll(fPath string) error {
dir := path.Dir(fPath)
files, ok := m.files[dir]
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion internal/models/main_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

return m, sequentially(
func() tea.Msg {
return osi.Remove(path.Join(m.cwd, m.files[m.cursorOffset()].Name()))
return osi.RemoveAll(path.Join(m.cwd, m.files[m.cursorOffset()].Name()))
},
m.loadDir(m.cwd),
)
Expand Down

0 comments on commit e5ef128

Please sign in to comment.