melib: s/get/fetch in MailBackend methods

master
Manos Pitsidianakis 2020-07-17 23:30:02 +03:00
parent 0a7f283582
commit 9103d05617
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
9 changed files with 30 additions and 30 deletions

View File

@ -294,8 +294,8 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
fn is_online_async(&self) -> ResultFuture<()> {
Err(MeliError::new("Unimplemented."))
}
fn get(&mut self, mailbox: &Mailbox) -> Result<Async<Result<Vec<Envelope>>>>;
fn get_async(
fn fetch(&mut self, mailbox: &Mailbox) -> Result<Async<Result<Vec<Envelope>>>>;
fn fetch_async(
&mut self,
_mailbox: &Mailbox,
) -> Result<Pin<Box<dyn Stream<Item = Result<Vec<Envelope>>> + Send + 'static>>> {

View File

@ -188,7 +188,7 @@ impl MailBackend for ImapType {
true
}
fn get_async(
fn fetch_async(
&mut self,
mailbox: &Mailbox,
) -> Result<Pin<Box<dyn Stream<Item = Result<Vec<Envelope>>> + Send + 'static>>> {
@ -200,10 +200,10 @@ impl MailBackend for ImapType {
let mut valid_hash_set: HashSet<EnvelopeHash> = HashSet::default();
let mut our_unseen: BTreeSet<EnvelopeHash> = Default::default();
Ok(Box::pin(async_stream::try_stream! {
let (cached_hash_set, cached_payload) = get_cached_envs(mailbox_hash, &mut our_unseen, &uid_store)?;
let (cached_hash_set, cached_payload) = fetch_cached_envs(mailbox_hash, &mut our_unseen, &uid_store)?;
yield cached_payload;
loop {
let res = get_hlpr(&connection, mailbox_hash,&cached_hash_set, &can_create_flags, &mut our_unseen, &mut valid_hash_set, &uid_store, &mut max_uid).await?;
let res = fetch_hlpr(&connection, mailbox_hash, &cached_hash_set, &can_create_flags, &mut our_unseen, &mut valid_hash_set, &uid_store, &mut max_uid).await?;
yield res;
if max_uid == Some(1) || max_uid == Some(0) {
return;
@ -297,7 +297,7 @@ impl MailBackend for ImapType {
}))
}
fn get(&mut self, _mailbox: &Mailbox) -> Result<Async<Result<Vec<Envelope>>>> {
fn fetch(&mut self, _mailbox: &Mailbox) -> Result<Async<Result<Vec<Envelope>>>> {
Err(MeliError::new("Unimplemented."))
}
@ -1010,7 +1010,7 @@ impl ImapType {
}
}
fn get_cached_envs(
fn fetch_cached_envs(
mailbox_hash: MailboxHash,
our_unseen: &mut BTreeSet<EnvelopeHash>,
uid_store: &UIDStore,
@ -1029,7 +1029,7 @@ fn get_cached_envs(
let cached_envs: (cache::MaxUID, Vec<(UID, Envelope)>);
cache::save_envelopes(uid_store.account_hash, mailbox_hash, *v, &[])
.chain_err_summary(|| "Could not save envelopes in cache in get()")?;
cached_envs = cache::get_envelopes(uid_store.account_hash, mailbox_hash, *v)
cached_envs = cache::fetch_envelopes(uid_store.account_hash, mailbox_hash, *v)
.chain_err_summary(|| "Could not get envelopes in cache in get()")?;
let (_max_uid, envelopes) = debug!(cached_envs);
let ret = envelopes.iter().map(|(_, env)| env.hash()).collect();
@ -1060,7 +1060,7 @@ fn get_cached_envs(
Ok((ret, payload))
}
async fn get_hlpr(
async fn fetch_hlpr(
connection: &Arc<FutureMutex<ImapConnection>>,
mailbox_hash: MailboxHash,
cached_hash_set: &HashSet<EnvelopeHash>,
@ -1085,7 +1085,7 @@ async fn get_hlpr(
return Ok(Vec::new());
}
let mut conn = connection.lock().await;
debug!("locked for get {}", mailbox_path);
debug!("locked for fetch {}", mailbox_path);
let mut response = String::with_capacity(8 * 1024);
let max_uid_left = if let Some(max_uid) = max_uid {
*max_uid

View File

@ -55,7 +55,7 @@ mod sqlite3_m {
CREATE INDEX IF NOT EXISTS envelope_idx ON envelopes(mailbox_hash, uid, validity);
CREATE INDEX IF NOT EXISTS uidvalidity_idx ON uidvalidity(mailbox_hash);";
pub fn get_envelopes(
pub fn fetch_envelopes(
account_hash: AccountHash,
mailbox_hash: MailboxHash,
uidvalidity: usize,
@ -155,7 +155,7 @@ pub use filesystem_m::*;
#[cfg(not(feature = "sqlite3"))]
mod filesystem_m {
use super::*;
pub fn get_envelopes(
pub fn fetch_envelopes(
_account_hash: AccountHash,
_mailbox_hash: MailboxHash,
_uidvalidity: usize,

View File

@ -212,7 +212,7 @@ impl MailBackend for JmapType {
self.online.lock().unwrap().1.clone()
}
fn get(&mut self, mailbox: &Mailbox) -> Result<Async<Result<Vec<Envelope>>>> {
fn fetch(&mut self, mailbox: &Mailbox) -> Result<Async<Result<Vec<Envelope>>>> {
let mut w = AsyncBuilder::new();
let mailboxes = self.mailboxes.clone();
let store = self.store.clone();

View File

@ -207,11 +207,11 @@ impl MailBackend for MaildirType {
Ok(Box::pin(async { res }))
}
fn get(&mut self, mailbox: &Mailbox) -> Result<Async<Result<Vec<Envelope>>>> {
fn fetch(&mut self, mailbox: &Mailbox) -> Result<Async<Result<Vec<Envelope>>>> {
Ok(self.multicore(4, mailbox))
}
fn get_async(
fn fetch_async(
&mut self,
mailbox: &Mailbox,
) -> Result<core::pin::Pin<Box<dyn Stream<Item = Result<Vec<Envelope>>> + Send + 'static>>>

View File

@ -718,7 +718,7 @@ impl MailBackend for MboxType {
Ok(())
}
fn get(&mut self, mailbox: &Mailbox) -> Result<Async<Result<Vec<Envelope>>>> {
fn fetch(&mut self, mailbox: &Mailbox) -> Result<Async<Result<Vec<Envelope>>>> {
let mut w = AsyncBuilder::new();
let handle = {
let tx = w.tx();

View File

@ -334,7 +334,7 @@ impl MailBackend for NotmuchDb {
Ok(())
}
fn get(&mut self, mailbox: &Mailbox) -> Result<Async<Result<Vec<Envelope>>>> {
fn fetch(&mut self, mailbox: &Mailbox) -> Result<Async<Result<Vec<Envelope>>>> {
let mut w = AsyncBuilder::new();
let mailbox_hash = mailbox.hash();
let database = NotmuchDb::new_connection(self.path.as_path(), self.lib.clone(), false);

View File

@ -161,7 +161,7 @@ pub enum JobRequest {
JoinHandle,
oneshot::Receiver<Result<HashMap<MailboxHash, Mailbox>>>,
),
Get(
Fetch(
MailboxHash,
JoinHandle,
oneshot::Receiver<(
@ -203,7 +203,7 @@ impl core::fmt::Debug for JobRequest {
match self {
JobRequest::Generic { name, .. } => write!(f, "JobRequest::Generic({})", name),
JobRequest::Mailboxes(_, _) => write!(f, "JobRequest::Mailboxes"),
JobRequest::Get(hash, _, _) => write!(f, "JobRequest::Get({})", hash),
JobRequest::Fetch(hash, _, _) => write!(f, "JobRequest::Fetch({})", hash),
JobRequest::IsOnline(_, _) => write!(f, "JobRequest::IsOnline"),
JobRequest::Refresh(_, _, _) => write!(f, "JobRequest::Refresh"),
JobRequest::SetFlags(_, _, _) => write!(f, "JobRequest::SetFlags"),
@ -238,9 +238,9 @@ impl JobRequest {
}
}
fn is_get(&self, mailbox_hash: MailboxHash) -> bool {
fn is_fetch(&self, mailbox_hash: MailboxHash) -> bool {
match self {
JobRequest::Get(h, _, _) if *h == mailbox_hash => true,
JobRequest::Fetch(h, _, _) if *h == mailbox_hash => true,
_ => false,
}
}
@ -531,7 +531,7 @@ impl Account {
if entry.conf.mailbox_conf.autoload {
entry.status = MailboxStatus::Parsing(0, 0);
if self.is_async {
if let Ok(mailbox_job) = self.backend.write().unwrap().get_async(&f) {
if let Ok(mailbox_job) = self.backend.write().unwrap().fetch_async(&f) {
let mailbox_job = mailbox_job.into_future();
let (rcvr, handle, job_id) =
self.job_executor.spawn_specialized(mailbox_job);
@ -541,7 +541,7 @@ impl Account {
)))
.unwrap();
self.active_jobs
.insert(job_id, JobRequest::Get(*h, handle, rcvr));
.insert(job_id, JobRequest::Fetch(*h, handle, rcvr));
}
} else {
entry.worker = match Account::new_worker(
@ -576,7 +576,7 @@ impl Account {
work_context: &WorkContext,
notify_fn: Arc<NotifyFn>,
) -> Result<Worker> {
let mut mailbox_handle = backend.write().unwrap().get(&mailbox)?;
let mut mailbox_handle = backend.write().unwrap().fetch(&mailbox)?;
let mut builder = AsyncBuilder::new();
let our_tx = builder.tx();
let mailbox_hash = mailbox.hash();
@ -1012,8 +1012,8 @@ impl Account {
}
MailboxStatus::None => {
if self.is_async {
if !self.active_jobs.values().any(|j| j.is_get(mailbox_hash)) {
match self.backend.write().unwrap().get_async(
if !self.active_jobs.values().any(|j| j.is_fetch(mailbox_hash)) {
match self.backend.write().unwrap().fetch_async(
&&self.mailbox_entries[&mailbox_hash].ref_mailbox,
) {
Ok(mailbox_job) => {
@ -1027,7 +1027,7 @@ impl Account {
.unwrap();
self.active_jobs.insert(
job_id,
JobRequest::Get(mailbox_hash, handle, rcvr),
JobRequest::Fetch(mailbox_hash, handle, rcvr),
);
}
Err(err) => {
@ -1633,7 +1633,7 @@ impl Account {
}
}
}
JobRequest::Get(mailbox_hash, _, mut chan) => {
JobRequest::Fetch(mailbox_hash, _, mut chan) => {
self.sender
.send(ThreadEvent::UIEvent(UIEvent::StatusEvent(
StatusEvent::JobFinished(*job_id),
@ -1667,7 +1667,7 @@ impl Account {
)))
.unwrap();
self.active_jobs
.insert(job_id, JobRequest::Get(mailbox_hash, handle, rcvr));
.insert(job_id, JobRequest::Fetch(mailbox_hash, handle, rcvr));
let payload = payload.unwrap();
if let Err(err) = payload {
self.mailbox_entries

View File

@ -98,7 +98,7 @@ impl MailBackend for PluginBackend {
}
}
fn get(&mut self, mailbox: &Mailbox) -> Result<Async<Result<Vec<Envelope>>>> {
fn fetch(&mut self, mailbox: &Mailbox) -> Result<Async<Result<Vec<Envelope>>>> {
let mut w = AsyncBuilder::new();
let _mailbox_hash = mailbox.hash();
let channel = self.channel.clone();