mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 05:16:28 +03:00
add DC_EVENT_DELETED_BLOB_FILE
This commit is contained in:
@@ -3934,6 +3934,16 @@ int64_t dc_lot_get_timestamp (const dc_lot_t* lot);
|
|||||||
*/
|
*/
|
||||||
#define DC_EVENT_NEW_BLOB_FILE 150
|
#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.
|
* The library-user should write a warning string to the log.
|
||||||
* Passed to the callback given to dc_context_new().
|
* Passed to the callback given to dc_context_new().
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ impl ContextWrapper {
|
|||||||
| Event::ImapMessageDeleted(msg)
|
| Event::ImapMessageDeleted(msg)
|
||||||
| Event::ImapMessageMoved(msg)
|
| Event::ImapMessageMoved(msg)
|
||||||
| Event::NewBlobFile(msg)
|
| Event::NewBlobFile(msg)
|
||||||
|
| Event::DeletedBlobFile(msg)
|
||||||
| Event::Warning(msg)
|
| Event::Warning(msg)
|
||||||
| Event::Error(msg)
|
| Event::Error(msg)
|
||||||
| Event::ErrorNetwork(msg)
|
| Event::ErrorNetwork(msg)
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ DC_EVENT_SMTP_MESSAGE_SENT = 103
|
|||||||
DC_EVENT_IMAP_MESSAGE_DELETED = 104
|
DC_EVENT_IMAP_MESSAGE_DELETED = 104
|
||||||
DC_EVENT_IMAP_MESSAGE_MOVED = 105
|
DC_EVENT_IMAP_MESSAGE_MOVED = 105
|
||||||
DC_EVENT_NEW_BLOB_FILE = 150
|
DC_EVENT_NEW_BLOB_FILE = 150
|
||||||
|
DC_EVENT_DELETED_BLOB_FILE = 151
|
||||||
DC_EVENT_WARNING = 300
|
DC_EVENT_WARNING = 300
|
||||||
DC_EVENT_ERROR = 400
|
DC_EVENT_ERROR = 400
|
||||||
DC_EVENT_ERROR_NETWORK = 401
|
DC_EVENT_ERROR_NETWORK = 401
|
||||||
|
|||||||
@@ -377,6 +377,7 @@ class TestOnlineAccount:
|
|||||||
self_addr = ac1.get_config("addr")
|
self_addr = ac1.get_config("addr")
|
||||||
ev = ac1._evlogger.get_matching("DC_EVENT_SMTP_MESSAGE_SENT")
|
ev = ac1._evlogger.get_matching("DC_EVENT_SMTP_MESSAGE_SENT")
|
||||||
assert self_addr in ev[2]
|
assert self_addr in ev[2]
|
||||||
|
ev = ac1._evlogger.get_matching("DC_EVENT_DELETED_BLOB_FILE")
|
||||||
|
|
||||||
ac1._evlogger.consume_events()
|
ac1._evlogger.consume_events()
|
||||||
lp.sec("send out message without bcc")
|
lp.sec("send out message without bcc")
|
||||||
@@ -386,6 +387,7 @@ class TestOnlineAccount:
|
|||||||
assert ev[2] == msg_out.id
|
assert ev[2] == msg_out.id
|
||||||
ev = ac1._evlogger.get_matching("DC_EVENT_SMTP_MESSAGE_SENT")
|
ev = ac1._evlogger.get_matching("DC_EVENT_SMTP_MESSAGE_SENT")
|
||||||
assert self_addr not in ev[2]
|
assert self_addr not in ev[2]
|
||||||
|
ev = ac1._evlogger.get_matching("DC_EVENT_DELETED_BLOB_FILE")
|
||||||
|
|
||||||
def test_mvbox_sentbox_threads(self, acfactory):
|
def test_mvbox_sentbox_threads(self, acfactory):
|
||||||
ac1 = acfactory.get_online_configuring_account(mvbox=True, sentbox=True)
|
ac1 = acfactory.get_online_configuring_account(mvbox=True, sentbox=True)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use rand::{thread_rng, Rng};
|
|||||||
|
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
|
use crate::events::Event;
|
||||||
|
|
||||||
pub(crate) fn dc_exactly_one_bit_set(v: libc::c_int) -> bool {
|
pub(crate) fn dc_exactly_one_bit_set(v: libc::c_int) -> bool {
|
||||||
0 != v && 0 == v & (v - 1)
|
0 != v && 0 == v & (v - 1)
|
||||||
@@ -512,10 +513,14 @@ pub(crate) fn dc_delete_file(context: &Context, path: impl AsRef<std::path::Path
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let dpath = format!("{}", path.as_ref().to_string_lossy());
|
||||||
match fs::remove_file(path_abs) {
|
match fs::remove_file(path_abs) {
|
||||||
Ok(_) => true,
|
Ok(_) => {
|
||||||
|
context.call_cb(Event::DeletedBlobFile(dpath));
|
||||||
|
true
|
||||||
|
}
|
||||||
Err(_err) => {
|
Err(_err) => {
|
||||||
warn!(context, "Cannot delete \"{}\".", path.as_ref().display());
|
warn!(context, "Cannot delete \"{}\".", dpath);
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,12 @@ pub enum Event {
|
|||||||
#[strum(props(id = "150"))]
|
#[strum(props(id = "150"))]
|
||||||
NewBlobFile(String),
|
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.
|
/// The library-user should write a warning string to the log.
|
||||||
/// Passed to the callback given to dc_context_new().
|
/// Passed to the callback given to dc_context_new().
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user