diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 67a0ac654..9a3563624 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -3934,6 +3934,16 @@ int64_t dc_lot_get_timestamp (const dc_lot_t* lot); */ #define DC_EVENT_NEW_BLOB_FILE 150 +/** + * Emitted when a blob file was successfully deleted + * + * @param data1 0 + * @param data2 (const char*) path name + * Must not be free()'d or modified and is valid only until the callback returns. + * @return 0 + */ +#define DC_EVENT_DELETED_BLOB_FILE 151 + /** * The library-user should write a warning string to the log. * Passed to the callback given to dc_context_new(). diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index fdce0e5ca..74bacc915 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -128,6 +128,7 @@ impl ContextWrapper { | Event::ImapMessageDeleted(msg) | Event::ImapMessageMoved(msg) | Event::NewBlobFile(msg) + | Event::DeletedBlobFile(msg) | Event::Warning(msg) | Event::Error(msg) | Event::ErrorNetwork(msg) diff --git a/python/src/deltachat/const.py b/python/src/deltachat/const.py index 64587ce68..cb7aec707 100644 --- a/python/src/deltachat/const.py +++ b/python/src/deltachat/const.py @@ -64,6 +64,7 @@ DC_EVENT_SMTP_MESSAGE_SENT = 103 DC_EVENT_IMAP_MESSAGE_DELETED = 104 DC_EVENT_IMAP_MESSAGE_MOVED = 105 DC_EVENT_NEW_BLOB_FILE = 150 +DC_EVENT_DELETED_BLOB_FILE = 151 DC_EVENT_WARNING = 300 DC_EVENT_ERROR = 400 DC_EVENT_ERROR_NETWORK = 401 diff --git a/python/tests/test_account.py b/python/tests/test_account.py index 2a0d29fd4..0356929ab 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -377,6 +377,7 @@ class TestOnlineAccount: self_addr = ac1.get_config("addr") ev = ac1._evlogger.get_matching("DC_EVENT_SMTP_MESSAGE_SENT") assert self_addr in ev[2] + ev = ac1._evlogger.get_matching("DC_EVENT_DELETED_BLOB_FILE") ac1._evlogger.consume_events() lp.sec("send out message without bcc") @@ -386,6 +387,7 @@ class TestOnlineAccount: assert ev[2] == msg_out.id ev = ac1._evlogger.get_matching("DC_EVENT_SMTP_MESSAGE_SENT") assert self_addr not in ev[2] + ev = ac1._evlogger.get_matching("DC_EVENT_DELETED_BLOB_FILE") def test_mvbox_sentbox_threads(self, acfactory): ac1 = acfactory.get_online_configuring_account(mvbox=True, sentbox=True) diff --git a/src/dc_tools.rs b/src/dc_tools.rs index 298a6c101..daeafaf6c 100644 --- a/src/dc_tools.rs +++ b/src/dc_tools.rs @@ -17,6 +17,7 @@ use rand::{thread_rng, Rng}; use crate::context::Context; use crate::error::Error; +use crate::events::Event; pub(crate) fn dc_exactly_one_bit_set(v: libc::c_int) -> bool { 0 != v && 0 == v & (v - 1) @@ -512,10 +513,14 @@ pub(crate) fn dc_delete_file(context: &Context, path: impl AsRef true, + Ok(_) => { + context.call_cb(Event::DeletedBlobFile(dpath)); + true + } Err(_err) => { - warn!(context, "Cannot delete \"{}\".", path.as_ref().display()); + warn!(context, "Cannot delete \"{}\".", dpath); false } } diff --git a/src/events.rs b/src/events.rs index 6e792d18a..a2cbc6512 100644 --- a/src/events.rs +++ b/src/events.rs @@ -60,6 +60,12 @@ pub enum Event { #[strum(props(id = "150"))] NewBlobFile(String), + /// Emitted when an new file in the $BLOBDIR was created + /// + /// @return 0 + #[strum(props(id = "151"))] + DeletedBlobFile(String), + /// The library-user should write a warning string to the log. /// Passed to the callback given to dc_context_new(). ///