man
This commit is contained in:
parent
706d397ad5
commit
49367abb58
6 changed files with 37 additions and 21 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
@ -649,11 +649,12 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "6.1.0"
|
||||
version = "6.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab6f70b46d6325aa300f1c7bb3d470127dfc27806d8ea6bf294ee0ce643ce2b1"
|
||||
checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2"
|
||||
dependencies = [
|
||||
"bitvec",
|
||||
"funty",
|
||||
"memchr",
|
||||
"version_check 0.9.2",
|
||||
]
|
||||
|
@ -786,8 +787,7 @@ name = "panorama-imap"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
"funty",
|
||||
"nom 6.1.0",
|
||||
"nom 6.1.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -961,9 +961,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570"
|
||||
checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
|
|
@ -12,8 +12,7 @@ edition = "2018"
|
|||
maintenance = { status = "passively-maintained" }
|
||||
|
||||
[dependencies]
|
||||
funty = "=1.1.0"
|
||||
nom = { version = "6", default-features = false, features = ["std"] }
|
||||
nom = { version = "6.1.2", default-features = false, features = ["std"] }
|
||||
|
||||
[dev-dependencies]
|
||||
assert_matches = "1.3"
|
||||
|
|
|
@ -106,6 +106,7 @@ async fn watcher_loop(
|
|||
// first try opening the config file directly when the program is opened
|
||||
// (so the config isn't blank until the user touches the config file)
|
||||
let xdg = BaseDirectories::new()?;
|
||||
|
||||
if let Some(config_path) = xdg.find_config_file("panorama/panorama.toml") {
|
||||
debug!("found config at {:?}", config_path);
|
||||
let config = read_config(config_path).await?;
|
||||
|
@ -118,10 +119,15 @@ async fn watcher_loop(
|
|||
debug!("new event: {:?}", event);
|
||||
use notify::DebouncedEvent::*;
|
||||
match event {
|
||||
NoticeWrite(path) | Write(path) => {
|
||||
let config = read_config(path).await?;
|
||||
NoticeWrite(path) | Write(path) => match read_config(path).await {
|
||||
Ok(config) => {
|
||||
debug!("read new config: {:?}", config);
|
||||
config_tx.send(Some(config))?;
|
||||
}
|
||||
Err(err) => {
|
||||
debug!("error reading new config: {:?}", err);
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +137,7 @@ async fn watcher_loop(
|
|||
|
||||
/// Start the entire config watcher system, and return a [ConfigWatcher][self::ConfigWatcher],
|
||||
/// which is a cloneable receiver of config update events.
|
||||
pub fn spawn_config_watcher() -> Result<(JoinHandle<()>, ConfigWatcher)> {
|
||||
pub fn spawn_config_watcher_system() -> Result<(JoinHandle<()>, ConfigWatcher)> {
|
||||
let (watcher, config_rx) = start_watcher()?;
|
||||
let (config_tx, config_update) = watch::channel(None);
|
||||
|
||||
|
|
9
src/mail/imap2.rs
Normal file
9
src/mail/imap2.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
// let's try this again
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::config::ImapConfig;
|
||||
|
||||
pub async fn open_imap_connection(config: ImapConfig) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
//! Mail
|
||||
|
||||
mod imap;
|
||||
mod imap2;
|
||||
|
||||
use anyhow::Result;
|
||||
use futures::stream::StreamExt;
|
||||
|
@ -23,18 +24,19 @@ pub enum MailCommand {
|
|||
|
||||
/// Main entrypoint for the mail listener.
|
||||
pub async fn run_mail(
|
||||
config_watcher: ConfigWatcher,
|
||||
mut config_watcher: ConfigWatcher,
|
||||
_cmd_in: UnboundedReceiver<MailCommand>,
|
||||
) -> Result<()> {
|
||||
let mut curr_conn: Option<JoinHandle<_>> = None;
|
||||
|
||||
let mut config_watcher = WatchStream::new(config_watcher);
|
||||
// let mut config_watcher = WatchStream::new(config_watcher);
|
||||
loop {
|
||||
debug!("listening for configs");
|
||||
let a = config_watcher.next().await;
|
||||
debug!("got config {:?}", a);
|
||||
let config: Config = match a {
|
||||
Some(Some(v)) => v,
|
||||
let config: Config = match config_watcher.changed().await {
|
||||
Ok(_) => match *config_watcher.borrow() {
|
||||
Some(ref v) => v.clone(),
|
||||
_ => break,
|
||||
},
|
||||
_ => break,
|
||||
};
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::path::PathBuf;
|
|||
|
||||
use anyhow::Result;
|
||||
use futures::future::TryFutureExt;
|
||||
use panorama::{config::spawn_config_watcher, mail, ui};
|
||||
use panorama::{config::spawn_config_watcher_system, mail, ui};
|
||||
use structopt::StructOpt;
|
||||
use tokio::sync::mpsc;
|
||||
use xdg::BaseDirectories;
|
||||
|
@ -31,7 +31,7 @@ async fn main() -> Result<()> {
|
|||
setup_logger(&opt)?;
|
||||
|
||||
let _xdg = BaseDirectories::new()?;
|
||||
let (_config_thread, config_update) = spawn_config_watcher()?;
|
||||
let (_config_thread, config_update) = spawn_config_watcher_system()?;
|
||||
|
||||
// used to notify the runtime that the process should exit
|
||||
let (exit_tx, mut exit_rx) = mpsc::channel::<()>(1);
|
||||
|
|
Loading…
Reference in a new issue