Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve recursive deletes #89

Merged
merged 1 commit into from
Mar 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions password/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ func (s *Store) gitAdd(files ...string) error {
if !s.isGit() {
return ErrGitNotInit
}
for i := range files {
files[i] = strings.TrimPrefix(files[i], s.path+"/")
}

args := []string{"add", "--all"}
args = append(args, files...)
Expand Down
13 changes: 7 additions & 6 deletions password/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,16 +400,17 @@ func (s *Store) Prune(tree string) error {
func (s *Store) delete(name string, recurse bool) error {
path := s.passfile(name)
rf := os.Remove
if recurse {
path = filepath.Join(s.path, name)
rf = os.RemoveAll
}

if !recurse && !fsutil.IsFile(path) {
return ErrNotFound
}
if recurse && !fsutil.IsDir(path) {
return ErrNotFound

if recurse && !fsutil.IsFile(path) {
path = filepath.Join(s.path, name)
rf = os.RemoveAll
if !fsutil.IsDir(path) {
return ErrNotFound
}
}

if err := rf(path); err != nil {
Expand Down