From ed1a07c0d06c80c5b1b5417d8e00f215740bfe62 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Mon, 22 Mar 2021 18:01:28 -0500 Subject: [PATCH] get rid of maildir --- Cargo.lock | 10 ------- Cargo.toml | 1 - maildir/Cargo.toml | 11 -------- maildir/src/lib.rs | 65 ---------------------------------------------- src/mail/client.rs | 1 - 5 files changed, 88 deletions(-) delete mode 100644 maildir/Cargo.toml delete mode 100644 maildir/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 57703ae..66e6c76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1860,16 +1860,6 @@ dependencies = [ "webpki-roots", ] -[[package]] -name = "panorama-maildir" -version = "0.1.0" -dependencies = [ - "anyhow", - "futures 0.3.13", - "tempfile", - "tokio 1.3.0", -] - [[package]] name = "panorama-smtp" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index cd7cb8a..e8a55a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,6 @@ license = "GPL-3.0-or-later" members = [ "imap", "smtp", - "maildir", ] [dependencies] diff --git a/maildir/Cargo.toml b/maildir/Cargo.toml deleted file mode 100644 index 650af4c..0000000 --- a/maildir/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "panorama-maildir" -version = "0.1.0" -authors = ["Michael Zhang "] -edition = "2018" - -[dependencies] -anyhow = "1.0.39" -futures = "0.3.13" -tempfile = "3.2.0" -tokio = { version = "1.3.0", features = ["full"] } diff --git a/maildir/src/lib.rs b/maildir/src/lib.rs deleted file mode 100644 index 1b85bfd..0000000 --- a/maildir/src/lib.rs +++ /dev/null @@ -1,65 +0,0 @@ -use std::path::{Path, PathBuf}; - -use anyhow::Result; -use tempfile::NamedTempFile; -use tokio::fs::{self, File, OpenOptions}; - -/// A Maildir, as defined by [Daniel J. Bernstein][1]. -/// -/// [1]: https://cr.yp.to/proto/maildir.html -pub struct Maildir { - path: PathBuf, -} - -impl Maildir { - // TODO: should this double as create (aka create tmp cur new if they don't exist)? - pub async fn open(path: impl AsRef) -> Result { - Ok(Maildir { - path: path.as_ref().to_path_buf(), - }) - } - - /// Stores a new message into the `new` directory - // TODO: maybe have a streaming option? - pub async fn store(&self, opts: StoreOptions) -> Result { - let unique_name = opts.create_unique_name(); - let tmp_file = self.tmp_dir().join(&unique_name); - { - let mut file = OpenOptions::new() - .create_new(true) // fail if the file already exists, this means we aren't unique! - .open(&tmp_file) - .await?; - } - - let new_file = self.new_dir().join(&unique_name); - fs::rename(&tmp_file, &new_file).await?; - Ok(new_file) - } - - /// Returns the path to the `tmp` subdirectory - #[inline] - pub fn tmp_dir(&self) -> PathBuf { - self.path.join("tmp") - } - - /// Returns the path to the `new` subdirectory - #[inline] - pub fn new_dir(&self) -> PathBuf { - self.path.join("new") - } - - /// Returns the path to the `cur` subdirectory - #[inline] - pub fn cur_dir(&self) -> PathBuf { - self.path.join("cur") - } -} - -/// Options that will be used to determine the filename it's stored to -pub struct StoreOptions {} - -impl StoreOptions { - pub fn create_unique_name(&self) -> String { - format!("") - } -} diff --git a/src/mail/client.rs b/src/mail/client.rs index 564ebb2..e8b707e 100644 --- a/src/mail/client.rs +++ b/src/mail/client.rs @@ -84,7 +84,6 @@ pub async fn imap_main( let mut message_list = authed.uid_fetch(&message_uids).await.unwrap(); while let Some((uid, attrs)) = message_list.next().await { let evt = MailEvent::UpdateUid(acct_name.clone(), uid, attrs); - // debug!("sent {:?}", evt); mail2ui_tx.send(evt); }