From 6affffd40b77e477670ec08fb752f63db79d4aaf Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Mon, 28 Sep 2015 17:36:41 +0200 Subject: [PATCH] remove photo on kill closes #30 --- storage.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/storage.c b/storage.c index 89dc09b..ea59a1b 100644 --- a/storage.c +++ b/storage.c @@ -969,6 +969,20 @@ JsonNode *kill_datastore(char *user, char *device) olog(LOG_NOTICE, "removed %s", UB(path)); } + /* Attempt to remove PHOTO ... */ + utstring_renew(path); + utstring_printf(path, "%s/photos/%s.png", STORAGEDIR, user); + if (remove(UB(path)) == 0) { + olog(LOG_NOTICE, "removed %s", UB(path)); + json_append_member(obj, "photo", json_mkstring(UB(path))); + } + + /* ... and parent directory */ + utstring_renew(path); + utstring_printf(path, "%s/photos/%s", STORAGEDIR, user); + if (rmdir(UB(path)) == 0) { + olog(LOG_NOTICE, "removed %s", UB(path)); + } json_append_member(obj, "killed", killed); return (obj);