aboutsummaryrefslogtreecommitdiffstats
path: root/src/cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cache.c')
-rw-r--r--src/cache.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/cache.c b/src/cache.c
index d1ce06e9d3..f25f05afd8 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -9,6 +9,7 @@
* by the Free Software Foundation. See http://www.gnu.org/ for details.
*/
+#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <dirent.h>
@@ -78,8 +79,10 @@ static void cache_clean_item(struct apk_database *db, int dirfd, const char *nam
if (apk_verbosity >= 2)
apk_message("deleting %s", name);
- if (!(apk_flags & APK_SIMULATE))
- unlinkat(dirfd, name, 0);
+ if (!(apk_flags & APK_SIMULATE)) {
+ if (unlinkat(dirfd, name, 0) < 0 && errno == EISDIR)
+ unlinkat(dirfd, name, AT_REMOVEDIR);
+ }
}
static int cache_clean(struct apk_database *db)