-@@ -221,6 +338,16 @@ static enum delret delete_dir_contents(c
- }
-
- strlcpy(p, fp->basename, remainder);
-+ if (detect_renamed) {
-+ if (S_ISDIR(fp->mode) && flags & DEL_NO_DELETIONS) {
-+ delete_dir_contents(fname, flags);
-+ continue;
-+ }
-+ if (S_ISREG(fp->mode))
-+ look_for_rename(fp, fname, dirlist->file_pool);
-+ if (flags & DEL_NO_DELETIONS)
-+ continue;
-+ }
- result = delete_item(fname, fp->mode, NULL, flags);
- if (result != DR_SUCCESS && ret == DR_SUCCESS)
- ret = result == DR_PINNED ? result : DR_NOT_EMPTY;
-@@ -239,15 +366,19 @@ static enum delret delete_dir_contents(c
+@@ -248,6 +365,8 @@ static enum delret delete_dir_contents(c
+ if (S_ISDIR(fp->mode)
+ && delete_dir_contents(fname, flags | DEL_RECURSE) != DR_SUCCESS)
+ ret = DR_NOT_EMPTY;
++ if (detect_renamed && S_ISREG(fp->mode))
++ look_for_rename(fp, fname, dirlist->file_pool);
+ if (delete_item(fname, fp->mode, NULL, flags) != DR_SUCCESS)
+ ret = DR_NOT_EMPTY;
+ }
+@@ -270,15 +389,19 @@ static enum delret delete_dir_contents(c