tDon't attempt to remove non existing files - pm - barely a pack manager
(HTM) git clone git://z3bra.org/pm
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 3520ebda244371812dd12b04da00df4fc986df18
(DIR) parent 505bcbe3ef7f29ac3f26f7d0b0f678a7efe53d55
(HTM) Author: z3bra <willyatmailoodotorg>
Date: Thu, 7 Jan 2016 14:58:21 +0100
Don't attempt to remove non existing files
Diffstat:
M pm.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/pm.c b/pm.c
t@@ -1,3 +1,4 @@
+#include <errno.h>
#include <dirent.h>
#include <fcntl.h>
#include <limits.h>
t@@ -365,7 +366,10 @@ delete_content(FILE *f)
len--;
}
- stat(file, &st);
+ /* if file doesn't exist anymore, it's all good :) */
+ if (stat(file, &st) < 0 && errno == ENOENT)
+ return 0;
+
if (S_ISDIR(st.st_mode) && is_empty(file))
return rmdir(file);