mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Add Attachment.deleteData
This commit is contained in:
@@ -142,3 +142,29 @@ exports.loadData = (readAttachmentData) => {
|
||||
return Object.assign({}, attachment, { data });
|
||||
};
|
||||
};
|
||||
|
||||
// deleteData :: (RelativePath -> IO Unit)
|
||||
// Attachment ->
|
||||
// IO Unit
|
||||
exports.deleteData = (deleteAttachmentData) => {
|
||||
if (!isFunction(deleteAttachmentData)) {
|
||||
throw new TypeError('`deleteAttachmentData` must be a function');
|
||||
}
|
||||
|
||||
return async (attachment) => {
|
||||
if (!exports.isValid(attachment)) {
|
||||
throw new TypeError('`attachment` is not valid');
|
||||
}
|
||||
|
||||
const hasDataInMemory = exports.hasData(attachment);
|
||||
if (hasDataInMemory) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isString(attachment.path)) {
|
||||
throw new TypeError('`attachment.path` is required');
|
||||
}
|
||||
|
||||
await deleteAttachmentData(attachment.path);
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user