refactor: rename cache module to archive

This commit is contained in:
rustmailer
2026-08-19 17:02:55 +08:00
parent 704678234b
commit d9097f85cf
24 changed files with 27 additions and 27 deletions

View File

@@ -11,7 +11,7 @@ use bichon_core::{
since::{DateSince, RelativeDate}, since::{DateSince, RelativeDate},
}, },
autoconfig::entity::MailServerConfig, autoconfig::entity::MailServerConfig,
cache::imap::mailbox::Attribute, archive::imap::mailbox::Attribute,
database::batch_insert_impl, database::batch_insert_impl,
error::{code::ErrorCode, BichonError, BichonResult}, error::{code::ErrorCode, BichonError, BichonResult},
raise_error, raise_error,
@@ -653,7 +653,7 @@ pub struct MailBox {
pub uid_validity: Option<u32>, pub uid_validity: Option<u32>,
} }
impl From<MailBox> for bichon_core::cache::imap::mailbox::MailBox { impl From<MailBox> for bichon_core::archive::imap::mailbox::MailBox {
fn from(value: MailBox) -> Self { fn from(value: MailBox) -> Self {
Self { Self {
id: value.id, id: value.id,
@@ -898,7 +898,7 @@ pub fn migrate_metadata(root_path: &PathBuf) -> Result<(), Box<dyn std::error::E
migrate_collection!( migrate_collection!(
"Mailboxes", "Mailboxes",
MailBox, MailBox,
bichon_core::cache::imap::mailbox::MailBox, bichon_core::archive::imap::mailbox::MailBox,
&envelope_db &envelope_db
); );

View File

@@ -27,7 +27,7 @@ use crate::{
since::{DateSince, RelativeDate}, since::{DateSince, RelativeDate},
state::DownloadState, state::DownloadState,
}, },
cache::imap::{mailbox::MailBox, task::SYNC_TASKS}, archive::imap::{mailbox::MailBox, task::SYNC_TASKS},
common::paginated::DataPage, common::paginated::DataPage,
context::controller::DOWNLOAD_CONTROLLER, context::controller::DOWNLOAD_CONTROLLER,
database::{ database::{

View File

@@ -22,8 +22,8 @@ use crate::{
decode_mailbox_name, raise_error, decode_mailbox_name, raise_error,
{ {
account::migration::{AccountModel, AccountType}, account::migration::{AccountModel, AccountType},
cache::imap::mailbox::{AttributeEnum, MailBox}, archive::imap::mailbox::{AttributeEnum, MailBox},
cache::imap::mailbox_cache, archive::imap::mailbox_cache,
error::{code::ErrorCode, BichonResult}, error::{code::ErrorCode, BichonResult},
imap::{executor::ImapExecutor, session::SessionStream}, imap::{executor::ImapExecutor, session::SessionStream},
mailbox::list::convert_names_to_mailboxes, mailbox::list::convert_names_to_mailboxes,

View File

@@ -23,7 +23,7 @@ use crate::{
migration::AccountModel, migration::AccountModel,
state::{DownloadState, DownloadStatus, FolderStatus}, state::{DownloadState, DownloadStatus, FolderStatus},
}, },
cache::{ archive::{
imap::{ imap::{
download::rebuild::{rebuild_mailbox_cache, rebuild_mailbox_cache_by_date}, download::rebuild::{rebuild_mailbox_cache, rebuild_mailbox_cache_by_date},
find_intersecting_mailboxes, find_missing_mailboxes, find_intersecting_mailboxes, find_missing_mailboxes,

View File

@@ -27,7 +27,7 @@ use crate::{
migration::AccountModel, migration::AccountModel,
state::{DownloadState, GapFillFolderStats, GapFillState}, state::{DownloadState, GapFillFolderStats, GapFillState},
}, },
cache::imap::mailbox::MailBox, archive::imap::mailbox::MailBox,
error::BichonResult, error::BichonResult,
imap::executor::{compress_uid_list, ImapExecutor, DEFAULT_BATCH_SIZE}, imap::executor::{compress_uid_list, ImapExecutor, DEFAULT_BATCH_SIZE},
store::tantivy::envelope::EnvelopeSnapshot, store::tantivy::envelope::EnvelopeSnapshot,
@@ -378,7 +378,7 @@ pub async fn gap_fill_mailbox(
if let Some(max_uid) = missing_uids.last().copied() { if let Some(max_uid) = missing_uids.last().copied() {
let mut updated = remote_mailbox.clone(); let mut updated = remote_mailbox.clone();
updated.highest_uid = Some(max_uid.max(local_mailbox.highest_uid.unwrap_or(0))); updated.highest_uid = Some(max_uid.max(local_mailbox.highest_uid.unwrap_or(0)));
crate::cache::imap::mailbox::MailBox::batch_upsert(&[updated])?; crate::archive::imap::mailbox::MailBox::batch_upsert(&[updated])?;
} }
} }

View File

@@ -24,7 +24,7 @@ use crate::{
TriggerType, TriggerType,
}, },
}, },
cache::imap::{download::flow::FetchDirection, mailbox::MailBox}, archive::imap::{download::flow::FetchDirection, mailbox::MailBox},
error::BichonResult, error::BichonResult,
imap::executor::ImapExecutor, imap::executor::ImapExecutor,
}; };

View File

@@ -21,7 +21,7 @@ use crate::{
migration::AccountModel, migration::AccountModel,
state::{DownloadState, DownloadStatus, FolderStatus}, state::{DownloadState, DownloadStatus, FolderStatus},
}, },
cache::{ archive::{
imap::{ imap::{
download::flow::{fetch_and_save_by_date, fetch_and_save_full_mailbox, FetchDirection}, download::flow::{fetch_and_save_by_date, fetch_and_save_full_mailbox, FetchDirection},
mailbox::MailBox, mailbox::MailBox,

View File

@@ -16,7 +16,7 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
use crate::cache::imap::mailbox::MailBox; use crate::archive::imap::mailbox::MailBox;
use crate::utc_now; use crate::utc_now;
use lru::LruCache; use lru::LruCache;
use std::collections::HashMap; use std::collections::HashMap;

View File

@@ -18,7 +18,7 @@
use crate::account::entity::AuthType; use crate::account::entity::AuthType;
use crate::account::state::{DownloadState, TriggerType}; use crate::account::state::{DownloadState, TriggerType};
use crate::cache::imap::download::process_imap_download; use crate::archive::imap::download::process_imap_download;
use crate::common::periodic::{PeriodicTask, TaskHandle}; use crate::common::periodic::{PeriodicTask, TaskHandle};
use crate::error::code::ErrorCode; use crate::error::code::ErrorCode;
use crate::oauth2::token::OAuth2AccessToken; use crate::oauth2::token::OAuth2AccessToken;

View File

@@ -16,7 +16,7 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
use crate::{cache::imap::task::SYNC_TASKS, error::BichonResult}; use crate::{archive::imap::task::SYNC_TASKS, error::BichonResult};
use std::{sync::LazyLock, time::Duration}; use std::{sync::LazyLock, time::Duration};
use tokio::sync::mpsc; use tokio::sync::mpsc;
use tracing::{error, info}; use tracing::{error, info};

View File

@@ -24,7 +24,7 @@ use uuid::Uuid;
use crate::{ use crate::{
account::migration::AccountModel, account::migration::AccountModel,
cache::imap::mailbox::MailBox, archive::imap::mailbox::MailBox,
common::AddrVec, common::AddrVec,
envelope::{meta::parse_bichon_metadata, utils::normalize_subject}, envelope::{meta::parse_bichon_metadata, utils::normalize_subject},
error::{code::ErrorCode, BichonResult}, error::{code::ErrorCode, BichonResult},

View File

@@ -18,7 +18,7 @@
use crate::account::migration::AccountModel; use crate::account::migration::AccountModel;
use crate::account::state::{DownloadState, DownloadStatus, FolderStatus}; use crate::account::state::{DownloadState, DownloadStatus, FolderStatus};
use crate::cache::imap::mailbox::MailBox; use crate::archive::imap::mailbox::MailBox;
use crate::envelope::extractor::extract_envelope_and_store_it; use crate::envelope::extractor::extract_envelope_and_store_it;
use crate::error::code::ErrorCode; use crate::error::code::ErrorCode;
use crate::imap::session::SessionStream; use crate::imap::session::SessionStream;
@@ -947,7 +947,7 @@ impl ImapExecutor {
progress: Option< progress: Option<
&(dyn Fn(u64, Option<f64>) -> BichonResult<()> + Send + Sync), &(dyn Fn(u64, Option<f64>) -> BichonResult<()> + Send + Sync),
>, >,
) -> BichonResult<Vec<crate::cache::imap::download::gap_fill::RemoteHeader>> { ) -> BichonResult<Vec<crate::archive::imap::download::gap_fill::RemoteHeader>> {
let mut stream = session let mut stream = session
.uid_fetch(uid_set, "(UID RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (MESSAGE-ID)])") .uid_fetch(uid_set, "(UID RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (MESSAGE-ID)])")
.await .await
@@ -1008,7 +1008,7 @@ impl ImapExecutor {
None => &[], None => &[],
}; };
let message_id = parse_message_id_header(header_bytes); let message_id = parse_message_id_header(header_bytes);
result.push(crate::cache::imap::download::gap_fill::RemoteHeader { result.push(crate::archive::imap::download::gap_fill::RemoteHeader {
uid, uid,
message_id, message_id,
size, size,

View File

@@ -27,7 +27,7 @@ use serde::{Deserialize, Serialize};
use crate::{ use crate::{
account::migration::{AccountModel, AccountType}, account::migration::{AccountModel, AccountType},
base64_decode_url_safe, base64_decode_url_safe,
cache::imap::mailbox::{Attribute, AttributeEnum, MailBox}, archive::imap::mailbox::{Attribute, AttributeEnum, MailBox},
envelope::extractor::{extract_envelope_from_eml, ExtractOutcome}, envelope::extractor::{extract_envelope_from_eml, ExtractOutcome},
error::{code::ErrorCode, BichonResult}, error::{code::ErrorCode, BichonResult},
raise_error, raise_error,

View File

@@ -2,7 +2,7 @@ pub mod account;
pub mod ext; pub mod ext;
pub mod admin; pub mod admin;
pub mod autoconfig; pub mod autoconfig;
pub mod cache; pub mod archive;
pub mod common; pub mod common;
pub mod context; pub mod context;
pub mod dashboard; pub mod dashboard;

View File

@@ -17,7 +17,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
use crate::{ use crate::{
cache::imap::mailbox::MailBox, archive::imap::mailbox::MailBox,
error::BichonResult, error::BichonResult,
store::tantivy::{attachment::ATTACHMENT_MANAGER, envelope::ENVELOPE_MANAGER}, store::tantivy::{attachment::ATTACHMENT_MANAGER, envelope::ENVELOPE_MANAGER},
}; };

View File

@@ -17,8 +17,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
use crate::account::migration::{AccountModel, AccountType}; use crate::account::migration::{AccountModel, AccountType};
use crate::cache::imap::mailbox::{Attribute, AttributeEnum, MailBox}; use crate::archive::imap::mailbox::{Attribute, AttributeEnum, MailBox};
use crate::cache::imap::mailbox_cache::{self, FetchStatus}; use crate::archive::imap::mailbox_cache::{self, FetchStatus};
use crate::error::code::ErrorCode; use crate::error::code::ErrorCode;
use crate::error::BichonResult; use crate::error::BichonResult;
use crate::imap::executor::ImapExecutor; use crate::imap::executor::ImapExecutor;

View File

@@ -28,7 +28,7 @@ use crate::{
raise_error, raise_error,
{ {
account::migration::AccountModel, account::migration::AccountModel,
cache::imap::mailbox::MailBox, archive::imap::mailbox::MailBox,
error::{code::ErrorCode, BichonResult}, error::{code::ErrorCode, BichonResult},
message::content::AttachmentInfo, message::content::AttachmentInfo,
store::{ store::{

View File

@@ -25,7 +25,7 @@ use std::sync::LazyLock;
use bichon_core::{ use bichon_core::{
bichon_version, bichon_version,
cache::imap::task::SYNC_TASKS, archive::imap::task::SYNC_TASKS,
common::{rustls::BichonTls, signal::SignalManager}, common::{rustls::BichonTls, signal::SignalManager},
context::{executors::BichonContext, Initialize}, context::{executors::BichonContext, Initialize},
database::manager::DB_MANAGER, database::manager::DB_MANAGER,

View File

@@ -27,7 +27,7 @@ use bichon_core::account::payload::{
use bichon_core::account::state::{DownloadState, GapFillState}; use bichon_core::account::state::{DownloadState, GapFillState};
use bichon_core::account::stats::AccountStats; use bichon_core::account::stats::AccountStats;
use bichon_core::account::view::AccountResp; use bichon_core::account::view::AccountResp;
use bichon_core::cache::imap::task::SYNC_TASKS; use bichon_core::archive::imap::task::SYNC_TASKS;
use bichon_core::common::paginated::{paginate_vec, DataPage}; use bichon_core::common::paginated::{paginate_vec, DataPage};
use bichon_core::error::code::ErrorCode; use bichon_core::error::code::ErrorCode;
use bichon_core::ext::event_bus::{emit, Event}; use bichon_core::ext::event_bus::{emit, Event};

View File

@@ -20,7 +20,7 @@ use std::{io, net::SocketAddr, time::Duration};
use base64::{prelude::BASE64_STANDARD, Engine as _}; use base64::{prelude::BASE64_STANDARD, Engine as _};
use bichon_core::{ use bichon_core::{
account::migration::{AccountModel, AccountType}, account::migration::{AccountModel, AccountType},
cache::imap::mailbox::{Attribute, AttributeEnum, MailBox}, archive::imap::mailbox::{Attribute, AttributeEnum, MailBox},
common::{auth::ClientContext, signal::SIGNAL_MANAGER}, common::{auth::ClientContext, signal::SIGNAL_MANAGER},
envelope::extractor::extract_envelope_from_smtp, envelope::extractor::extract_envelope_from_smtp,
error::BichonResult, error::BichonResult,