get rid of maildir

This commit is contained in:
Michael Zhang 2021-03-22 18:01:28 -05:00
parent aba067266d
commit ed1a07c0d0
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
5 changed files with 0 additions and 88 deletions

10
Cargo.lock generated
View file

@ -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"

View file

@ -12,7 +12,6 @@ license = "GPL-3.0-or-later"
members = [
"imap",
"smtp",
"maildir",
]
[dependencies]

View file

@ -1,11 +0,0 @@
[package]
name = "panorama-maildir"
version = "0.1.0"
authors = ["Michael Zhang <mail@mzhang.io>"]
edition = "2018"
[dependencies]
anyhow = "1.0.39"
futures = "0.3.13"
tempfile = "3.2.0"
tokio = { version = "1.3.0", features = ["full"] }

View file

@ -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<Path>) -> Result<Self> {
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<PathBuf> {
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!("")
}
}

View file

@ -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);
}