Add Attachments.deleteData

This commit is contained in:
Daniel Gasienica 2018-03-19 19:50:14 -04:00
parent 9b636a1885
commit 10afcf1bb0
2 changed files with 43 additions and 0 deletions

View file

@ -67,6 +67,22 @@ exports.writeData = (root) => {
};
};
// deleteData :: AttachmentsPath -> IO Unit
exports.deleteData = (root) => {
if (!isString(root)) {
throw new TypeError('`root` must be a path');
}
return async (relativePath) => {
if (!isString(relativePath)) {
throw new TypeError('`relativePath` must be a string');
}
const absolutePath = path.join(root, relativePath);
await fse.remove(absolutePath);
};
};
// createName :: Unit -> IO String
exports.createName = () => {
const buffer = crypto.randomBytes(32);