Skip to content
Snippets Groups Projects
Commit 5e025ef3 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Fix bug in recursive use of delfiles(), not deleting all subdirs/files

Looks like this feature (commit d661427e) never really worked correctly
since it counted the files removed from each sub-dir and then stopped deleting
when the count reached the number of files in the base directory. This was
done to accommodate the 'keep' feature (part of previous commits).
So make 'keep' check conditional on it being non-zero and just don't ever use
a non-zero keep value with a recursive delete and we should be good! :-)

This fixes issue #841
parent 169b770f
No related branches found
No related tags found
No related merge requests found
......@@ -813,7 +813,9 @@ int delfiles(const char *inpath, const char *spec, size_t keep)
free(path);
if(keep >= g.gl_pathc)
return 0;
for(i = 0; i < g.gl_pathc && files < g.gl_pathc - keep; i++) {
for(i = 0; i < g.gl_pathc; i++) {
if(keep > 0 && files >= g.gl_pathc - keep)
break;
fpath = g.gl_pathv[i];
if(isdir(fpath)) {
fname = getfname(fpath);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment