Commit 94dcbf83 authored by Wayne Davison's avatar Wayne Davison

- Iterate through the deletion list in reverse order so that we

  can't delete a backup file that we just created.
- The rename-directory-for-backup heuristic now checks the
  DEL_FORCE_RECURSE flag, not the zap_dir variable.  We also set
  the flag when we recurse so that only the root dir of a deleted
  hierarchy can be missing the flag (and thus be a call from the
  generator).
parent 1bad11c7
......@@ -1816,7 +1816,7 @@ int delete_file(char *fname, int mode, int flags)
ok = 0;
errno = ENOTEMPTY;
} else if (make_backups && !backup_dir && !is_backup_file(fname)
&& !zap_dir)
&& !(flags & DEL_FORCE_RECURSE))
ok = make_backup(fname);
else
ok = do_rmdir(fname) == 0;
......@@ -1833,9 +1833,10 @@ int delete_file(char *fname, int mode, int flags)
full_fname(fname));
return -1;
}
flags |= DEL_FORCE_RECURSE;
dirlist = get_dirlist(fname, 0);
for (j = 0; j < dirlist->count; j++) {
for (j = dirlist->count; j-- > 0; ) {
struct file_struct *fp = dirlist->files[j];
f_name_to(fp, buf);
if (delete_file(buf, fp->mode, flags & ~DEL_TERSE) != 0) {
......@@ -1882,8 +1883,7 @@ static void delete_missing(struct file_list *full_list,
if (flist_find(full_list, dir_list->files[i]) < 0) {
char *fn = f_name_to(dir_list->files[i], fbuf);
int mode = dir_list->files[i]->mode;
int dflag = S_ISDIR(mode) ? DEL_FORCE_RECURSE : 0;
if (delete_file(fn, mode, dflag) < 0)
if (delete_file(fn, mode, DEL_FORCE_RECURSE) < 0)
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment