Remove card on kill

closes #26
This commit is contained in:
Jan-Piet Mens
2015-09-17 11:21:44 +02:00
parent 1b12ada603
commit 9d26e3f29a
+15
View File
@@ -948,6 +948,21 @@ JsonNode *kill_datastore(char *user, char *device)
olog(LOG_NOTICE, "removed %s", utstring_body(path));
}
/* Attempt to remove CARD ... */
utstring_renew(path);
utstring_printf(path, "%s/cards/%s/%s.json", STORAGEDIR, user, user);
if (remove(utstring_body(path)) == 0) {
olog(LOG_NOTICE, "removed %s", utstring_body(path));
json_append_member(obj, "card", json_mkstring(utstring_body(path)));
}
/* ... and it's parent directory */
utstring_renew(path);
utstring_printf(path, "%s/cards/%s", STORAGEDIR, user);
if (rmdir(utstring_body(path)) == 0) {
olog(LOG_NOTICE, "removed %s", utstring_body(path));
}
json_append_member(obj, "killed", killed);
return (obj);