add debug! macro to replace eprintlns
parent
9143b2e791
commit
fb406667ab
|
@ -18,6 +18,43 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#[macro_use]
|
||||||
|
pub mod dbg {
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! debug {
|
||||||
|
($val:expr) => {
|
||||||
|
if cfg!(debug_assertions) {
|
||||||
|
eprint!(
|
||||||
|
"[{:?}] {}:{}_{}: ",
|
||||||
|
std::thread::current()
|
||||||
|
.name()
|
||||||
|
.map(|v| v.to_string())
|
||||||
|
.unwrap_or_else(|| format!("{:?}", std::thread::current().id())),
|
||||||
|
file!(),
|
||||||
|
line!(),
|
||||||
|
column!()
|
||||||
|
);
|
||||||
|
eprintln!("{}", $val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
($fmt:literal, $($arg:tt)*) => {
|
||||||
|
if cfg!(debug_assertions) {
|
||||||
|
eprint!(
|
||||||
|
"[{:?}] {}:{}_{}: ",
|
||||||
|
std::thread::current()
|
||||||
|
.name()
|
||||||
|
.map(|v| v.to_string())
|
||||||
|
.unwrap_or_else(|| format!("{:?}", std::thread::current().id())),
|
||||||
|
file!(),
|
||||||
|
line!(),
|
||||||
|
column!()
|
||||||
|
);
|
||||||
|
eprintln!($fmt, $($arg)*);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub mod addressbook;
|
pub mod addressbook;
|
||||||
pub mod async_workers;
|
pub mod async_workers;
|
||||||
pub mod conf;
|
pub mod conf;
|
||||||
|
|
|
@ -120,16 +120,12 @@ impl Mailbox {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_reply(&mut self, envelope: &Envelope) {
|
pub fn insert_reply(&mut self, envelope: &Envelope) {
|
||||||
if cfg!(debug_assertions) {
|
debug!("mailbox insert reply {}", self.name);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("mailbox insert reply {}", self.name);
|
|
||||||
}
|
|
||||||
self.collection.insert_reply(envelope);
|
self.collection.insert_reply(envelope);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove(&mut self, envelope_hash: EnvelopeHash) {
|
pub fn remove(&mut self, envelope_hash: EnvelopeHash) {
|
||||||
self.collection.remove(envelope_hash);
|
self.collection.remove(envelope_hash);
|
||||||
// if cfg!(debug_assertions) { eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
// debug!("envelope_hash: {}\ncollection:\n{:?}", envelope_hash, self.collection);
|
||||||
// eprintln!("envelope_hash: {}\ncollection:\n{:?}", envelope_hash, self.collection); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,20 +66,11 @@ impl MaildirOp {
|
||||||
fn path(&self) -> PathBuf {
|
fn path(&self) -> PathBuf {
|
||||||
let map = self.hash_index.lock().unwrap();
|
let map = self.hash_index.lock().unwrap();
|
||||||
let map = &map[&self.folder_hash];
|
let map = &map[&self.folder_hash];
|
||||||
if cfg!(debug_assertions) {
|
debug!("looking for {} in {} map", self.hash, self.folder_hash);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("looking for {} in {} map", self.hash, self.folder_hash);
|
|
||||||
}
|
|
||||||
if !map.contains_key(&self.hash) {
|
if !map.contains_key(&self.hash) {
|
||||||
if cfg!(debug_assertions) {
|
debug!("doesn't contain it though len = {}\n{:#?}", map.len(), map);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("doesn't contain it though len = {}\n{:#?}", map.len(), map);
|
|
||||||
}
|
|
||||||
for e in map.iter() {
|
for e in map.iter() {
|
||||||
if cfg!(debug_assertions) {
|
debug!("{:#?}", e);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("{:#?}", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
map.get(&self.hash).unwrap().clone()
|
map.get(&self.hash).unwrap().clone()
|
||||||
|
@ -125,8 +116,7 @@ impl<'a> BackendOp for MaildirOp {
|
||||||
'S' => flag |= Flag::SEEN,
|
'S' => flag |= Flag::SEEN,
|
||||||
'T' => flag |= Flag::TRASHED,
|
'T' => flag |= Flag::TRASHED,
|
||||||
_ => {
|
_ => {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("DEBUG: in fetch_flags, path is {}", path);
|
||||||
eprintln!("DEBUG: in fetch_flags, path is {}", path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,15 +156,9 @@ impl<'a> BackendOp for MaildirOp {
|
||||||
new_name.push('T');
|
new_name.push('T');
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg!(debug_assertions) {
|
debug!("renaming {:?} to {:?}", path, new_name);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("renaming {:?} to {:?}", path, new_name);
|
|
||||||
}
|
|
||||||
fs::rename(&path, &new_name)?;
|
fs::rename(&path, &new_name)?;
|
||||||
if cfg!(debug_assertions) {
|
debug!("success in rename");
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("success in rename");
|
|
||||||
}
|
|
||||||
let old_hash = envelope.hash();
|
let old_hash = envelope.hash();
|
||||||
let new_name: PathBuf = new_name.into();
|
let new_name: PathBuf = new_name.into();
|
||||||
let new_hash = get_file_hash(&new_name);
|
let new_hash = get_file_hash(&new_name);
|
||||||
|
|
|
@ -137,10 +137,7 @@ fn move_to_cur(p: PathBuf) -> PathBuf {
|
||||||
if !file_name.ends_with(":2,") {
|
if !file_name.ends_with(":2,") {
|
||||||
new.set_extension(":2,");
|
new.set_extension(":2,");
|
||||||
}
|
}
|
||||||
if cfg!(debug_assertions) {
|
debug!("moved to cur: {}", new.display());
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("moved to cur: {}", new.display());
|
|
||||||
}
|
|
||||||
fs::rename(p, &new).unwrap();
|
fs::rename(p, &new).unwrap();
|
||||||
new
|
new
|
||||||
}
|
}
|
||||||
|
@ -161,10 +158,7 @@ impl MailBackend for MaildirType {
|
||||||
let root_path = self.path.to_path_buf();
|
let root_path = self.path.to_path_buf();
|
||||||
watcher.watch(&root_path, RecursiveMode::Recursive).unwrap();
|
watcher.watch(&root_path, RecursiveMode::Recursive).unwrap();
|
||||||
let cache_dir = xdg::BaseDirectories::with_profile("meli", &self.name).unwrap();
|
let cache_dir = xdg::BaseDirectories::with_profile("meli", &self.name).unwrap();
|
||||||
if cfg!(debug_assertions) {
|
debug!("watching {:?}", root_path);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("watching {:?}", root_path);
|
|
||||||
}
|
|
||||||
let hash_indexes = self.hash_indexes.clone();
|
let hash_indexes = self.hash_indexes.clone();
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name("folder watch".to_string())
|
.name("folder watch".to_string())
|
||||||
|
@ -186,11 +180,9 @@ impl MailBackend for MaildirType {
|
||||||
Ok(event) => match event {
|
Ok(event) => match event {
|
||||||
/* Create */
|
/* Create */
|
||||||
DebouncedEvent::Create(mut pathbuf) => {
|
DebouncedEvent::Create(mut pathbuf) => {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("DebouncedEvent::Create(path = {:?}", pathbuf);
|
||||||
eprintln!("DebouncedEvent::Create(path = {:?}", pathbuf);
|
|
||||||
if path_is_new!(pathbuf) {
|
if path_is_new!(pathbuf) {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("path_is_new");
|
||||||
eprintln!("path_is_new");
|
|
||||||
/* This creates a Rename event that we will receive later */
|
/* This creates a Rename event that we will receive later */
|
||||||
pathbuf = move_to_cur(pathbuf);
|
pathbuf = move_to_cur(pathbuf);
|
||||||
}
|
}
|
||||||
|
@ -200,8 +192,6 @@ eprintln!("path_is_new");
|
||||||
.strip_prefix(&root_path)
|
.strip_prefix(&root_path)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_path_buf();
|
.to_path_buf();
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("cilename is {:?}", file_name);
|
|
||||||
if let Some(env) = add_path_to_index(
|
if let Some(env) = add_path_to_index(
|
||||||
&hash_indexes,
|
&hash_indexes,
|
||||||
folder_hash,
|
folder_hash,
|
||||||
|
@ -209,10 +199,7 @@ eprintln!("cilename is {:?}", file_name);
|
||||||
&cache_dir,
|
&cache_dir,
|
||||||
file_name,
|
file_name,
|
||||||
) {
|
) {
|
||||||
if cfg!(debug_assertions) {
|
debug!("Create event {} {} {}", env.hash(), env.subject(), pathbuf.display());
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("Create event {} {} {}", env.hash(), env.subject(), pathbuf.display());
|
|
||||||
}
|
|
||||||
sender.send(RefreshEvent {
|
sender.send(RefreshEvent {
|
||||||
hash: folder_hash,
|
hash: folder_hash,
|
||||||
kind: Create(Box::new(env)),
|
kind: Create(Box::new(env)),
|
||||||
|
@ -222,8 +209,7 @@ eprintln!("Create event {} {} {}", env.hash(), env.subject(), pathbuf.display())
|
||||||
/* Update */
|
/* Update */
|
||||||
DebouncedEvent::NoticeWrite(pathbuf)
|
DebouncedEvent::NoticeWrite(pathbuf)
|
||||||
| DebouncedEvent::Write(pathbuf) => {
|
| DebouncedEvent::Write(pathbuf) => {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("DebouncedEvent::Write(path = {:?}", &pathbuf);
|
||||||
eprintln!("DebouncedEvent::Write(path = {:?}", pathbuf);
|
|
||||||
let folder_hash = get_path_hash!(pathbuf);
|
let folder_hash = get_path_hash!(pathbuf);
|
||||||
let mut hash_indexes_lock = hash_indexes.lock().unwrap();
|
let mut hash_indexes_lock = hash_indexes.lock().unwrap();
|
||||||
let index_lock = &mut hash_indexes_lock.entry(folder_hash).or_default();
|
let index_lock = &mut hash_indexes_lock.entry(folder_hash).or_default();
|
||||||
|
@ -260,14 +246,11 @@ eprintln!("DebouncedEvent::Write(path = {:?}", pathbuf);
|
||||||
};
|
};
|
||||||
let new_hash: EnvelopeHash = get_file_hash(pathbuf.as_path());
|
let new_hash: EnvelopeHash = get_file_hash(pathbuf.as_path());
|
||||||
if index_lock.get_mut(&new_hash).is_none() {
|
if index_lock.get_mut(&new_hash).is_none() {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("write notice");
|
||||||
eprintln!("write notice");
|
|
||||||
let op = Box::new(MaildirOp::new(new_hash, hash_indexes.clone(), folder_hash));
|
let op = Box::new(MaildirOp::new(new_hash, hash_indexes.clone(), folder_hash));
|
||||||
if let Some(env) = Envelope::from_token(op, new_hash) {
|
if let Some(env) = Envelope::from_token(op, new_hash) {
|
||||||
if cfg!(debug_assertions) {
|
debug!("{}\t{:?}", new_hash, &pathbuf);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("hash {}, path: {:?} couldn't be parsed in `add_path_to_index`", new_hash, &pathbuf);
|
||||||
eprintln!("{}\t{}", new_hash, pathbuf.display());
|
|
||||||
}
|
|
||||||
index_lock.insert(new_hash, pathbuf);
|
index_lock.insert(new_hash, pathbuf);
|
||||||
|
|
||||||
/* Send Write notice */
|
/* Send Write notice */
|
||||||
|
@ -276,17 +259,13 @@ eprintln!("{}\t{}", new_hash, pathbuf.display());
|
||||||
hash: folder_hash,
|
hash: folder_hash,
|
||||||
kind: Update(old_hash, Box::new(env)),
|
kind: Update(old_hash, Box::new(env)),
|
||||||
});
|
});
|
||||||
} else if cfg!(debug_assertions) {
|
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("DEBUG: hash {}, path: {} couldn't be parsed in `add_path_to_index`", new_hash, pathbuf.as_path().display());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Remove */
|
/* Remove */
|
||||||
DebouncedEvent::NoticeRemove(pathbuf)
|
DebouncedEvent::NoticeRemove(pathbuf)
|
||||||
| DebouncedEvent::Remove(pathbuf) => {
|
| DebouncedEvent::Remove(pathbuf) => {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("DebouncedEvent::Remove(path = {:?}", pathbuf);
|
||||||
eprintln!("DebouncedEvent::Remove(path = {:?}", pathbuf);
|
|
||||||
let folder_hash = get_path_hash!(pathbuf);
|
let folder_hash = get_path_hash!(pathbuf);
|
||||||
let mut hash_indexes_lock = hash_indexes.lock().unwrap();
|
let mut hash_indexes_lock = hash_indexes.lock().unwrap();
|
||||||
let index_lock = hash_indexes_lock.entry(folder_hash).or_default();
|
let index_lock = hash_indexes_lock.entry(folder_hash).or_default();
|
||||||
|
@ -295,8 +274,7 @@ eprintln!("DebouncedEvent::Remove(path = {:?}", pathbuf);
|
||||||
{
|
{
|
||||||
*k
|
*k
|
||||||
} else {
|
} else {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("removed but not contained in index");
|
||||||
eprintln!("removed but not contained in index");
|
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
index_lock.remove(&hash);
|
index_lock.remove(&hash);
|
||||||
|
@ -308,10 +286,7 @@ eprintln!("removed but not contained in index");
|
||||||
}
|
}
|
||||||
/* Envelope hasn't changed */
|
/* Envelope hasn't changed */
|
||||||
DebouncedEvent::Rename(src, dest) => {
|
DebouncedEvent::Rename(src, dest) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("DebouncedEvent::Rename(src = {:?}, dest = {:?})", src, dest);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("DebouncedEvent::Rename(src = {:?}, dest = {:?})", src, dest);
|
|
||||||
}
|
|
||||||
let folder_hash = get_path_hash!(src);
|
let folder_hash = get_path_hash!(src);
|
||||||
let old_hash: EnvelopeHash = get_file_hash(src.as_path());
|
let old_hash: EnvelopeHash = get_file_hash(src.as_path());
|
||||||
let new_hash: EnvelopeHash = get_file_hash(dest.as_path());
|
let new_hash: EnvelopeHash = get_file_hash(dest.as_path());
|
||||||
|
@ -320,10 +295,7 @@ eprintln!("removed but not contained in index");
|
||||||
let index_lock = hash_indexes_lock.entry(folder_hash).or_default();
|
let index_lock = hash_indexes_lock.entry(folder_hash).or_default();
|
||||||
|
|
||||||
if index_lock.contains_key(&old_hash) {
|
if index_lock.contains_key(&old_hash) {
|
||||||
if cfg!(debug_assertions) {
|
debug!("contains_old_key");
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("contains_old_key");
|
|
||||||
}
|
|
||||||
sender.send(RefreshEvent {
|
sender.send(RefreshEvent {
|
||||||
hash: get_path_hash!(dest),
|
hash: get_path_hash!(dest),
|
||||||
kind: Rename(old_hash, new_hash),
|
kind: Rename(old_hash, new_hash),
|
||||||
|
@ -332,19 +304,13 @@ eprintln!("removed but not contained in index");
|
||||||
index_lock.insert(new_hash, dest);
|
index_lock.insert(new_hash, dest);
|
||||||
continue;
|
continue;
|
||||||
} else if !index_lock.contains_key(&new_hash) {
|
} else if !index_lock.contains_key(&new_hash) {
|
||||||
if cfg!(debug_assertions) {
|
debug!("not contains_new_key");
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("not contains_new_key");
|
|
||||||
}
|
|
||||||
let file_name = dest
|
let file_name = dest
|
||||||
.as_path()
|
.as_path()
|
||||||
.strip_prefix(&root_path)
|
.strip_prefix(&root_path)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_path_buf();
|
.to_path_buf();
|
||||||
if cfg!(debug_assertions) {
|
debug!("filename = {:?}", file_name);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("filename = {:?}", file_name);
|
|
||||||
}
|
|
||||||
if let Some(env) = add_path_to_index(
|
if let Some(env) = add_path_to_index(
|
||||||
&hash_indexes,
|
&hash_indexes,
|
||||||
folder_hash,
|
folder_hash,
|
||||||
|
@ -352,30 +318,21 @@ eprintln!("removed but not contained in index");
|
||||||
&cache_dir,
|
&cache_dir,
|
||||||
file_name,
|
file_name,
|
||||||
) {
|
) {
|
||||||
if cfg!(debug_assertions) {
|
debug!("Create event {} {} {}", env.hash(), env.subject(), dest.display());
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("Create event {} {} {}", env.hash(), env.subject(), dest.display());
|
|
||||||
}
|
|
||||||
sender.send(RefreshEvent {
|
sender.send(RefreshEvent {
|
||||||
hash: folder_hash,
|
hash: folder_hash,
|
||||||
kind: Create(Box::new(env)),
|
kind: Create(Box::new(env)),
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if cfg!(debug_assertions) {
|
debug!("not valid email");
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("not valid email");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.send(RefreshEvent {
|
sender.send(RefreshEvent {
|
||||||
hash: get_path_hash!(dest),
|
hash: get_path_hash!(dest),
|
||||||
kind: Rename(old_hash, new_hash),
|
kind: Rename(old_hash, new_hash),
|
||||||
});
|
});
|
||||||
if cfg!(debug_assertions) {
|
debug!("contains_new_key");
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("contains_new_key");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Maybe a re-read should be triggered here just to be safe.
|
/* Maybe a re-read should be triggered here just to be safe.
|
||||||
|
@ -393,10 +350,7 @@ eprintln!("removed but not contained in index");
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("watch error: {:?}", e)
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("watch error: {:?}", e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,10 +390,7 @@ eprintln!("removed but not contained in index");
|
||||||
hostn_buf.trim()
|
hostn_buf.trim()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if cfg!(debug_assertions) {
|
debug!("saving at {}", path.display());
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("saving at {}", path.display());
|
|
||||||
}
|
|
||||||
let file = fs::File::create(path).unwrap();
|
let file = fs::File::create(path).unwrap();
|
||||||
let mut writer = io::BufWriter::new(file);
|
let mut writer = io::BufWriter::new(file);
|
||||||
writer.write_all(bytes).unwrap();
|
writer.write_all(bytes).unwrap();
|
||||||
|
@ -672,10 +623,7 @@ impl MaildirType {
|
||||||
}
|
}
|
||||||
local_r.push(e);
|
local_r.push(e);
|
||||||
} else {
|
} else {
|
||||||
if cfg!(debug_assertions) {
|
debug!("DEBUG: hash {}, path: {} couldn't be parsed in `add_path_to_index`", hash, file.as_path().display());
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("DEBUG: hash {}, path: {} couldn't be parsed in `add_path_to_index`", hash, file.as_path().display());
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -710,15 +658,13 @@ fn add_path_to_index(
|
||||||
file_name: PathBuf,
|
file_name: PathBuf,
|
||||||
) -> Option<Envelope> {
|
) -> Option<Envelope> {
|
||||||
let env: Envelope;
|
let env: Envelope;
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("add_path_to_index path {:?} filename{:?}", path, file_name);
|
||||||
eprintln!("add_path_to_index path {:?} filename{:?}", path, file_name);
|
|
||||||
let hash = get_file_hash(path);
|
let hash = get_file_hash(path);
|
||||||
{
|
{
|
||||||
let mut map = hash_index.lock().unwrap();
|
let mut map = hash_index.lock().unwrap();
|
||||||
let map = map.entry(folder_hash).or_default();;
|
let map = map.entry(folder_hash).or_default();;
|
||||||
map.insert(hash, path.to_path_buf());
|
map.insert(hash, path.to_path_buf());
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!(
|
||||||
eprintln!(
|
|
||||||
"inserted {} in {} map, len={}",
|
"inserted {} in {} map, len={}",
|
||||||
hash,
|
hash,
|
||||||
folder_hash,
|
folder_hash,
|
||||||
|
@ -727,11 +673,9 @@ fn add_path_to_index(
|
||||||
}
|
}
|
||||||
let op = Box::new(MaildirOp::new(hash, hash_index.clone(), folder_hash));
|
let op = Box::new(MaildirOp::new(hash, hash_index.clone(), folder_hash));
|
||||||
if let Some(e) = Envelope::from_token(op, hash) {
|
if let Some(e) = Envelope::from_token(op, hash) {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("add_path_to_index gen {}\t{}", hash, file_name.display());
|
||||||
eprintln!("add_path_to_index gen {}\t{}", hash, file_name.display());
|
|
||||||
if let Ok(cached) = cache_dir.place_cache_file(file_name) {
|
if let Ok(cached) = cache_dir.place_cache_file(file_name) {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("putting in cache");
|
||||||
eprintln!("putting in cache");
|
|
||||||
/* place result in cache directory */
|
/* place result in cache directory */
|
||||||
let f = match fs::File::create(cached) {
|
let f = match fs::File::create(cached) {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
|
@ -744,8 +688,7 @@ fn add_path_to_index(
|
||||||
}
|
}
|
||||||
env = e;
|
env = e;
|
||||||
} else {
|
} else {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!(
|
||||||
eprintln!(
|
|
||||||
"DEBUG: hash {}, path: {} couldn't be parsed in `add_path_to_index`",
|
"DEBUG: hash {}, path: {} couldn't be parsed in `add_path_to_index`",
|
||||||
hash,
|
hash,
|
||||||
path.display()
|
path.display()
|
||||||
|
|
|
@ -52,27 +52,24 @@ impl Collection {
|
||||||
let threads = Threads::new(&mut envelopes);
|
let threads = Threads::new(&mut envelopes);
|
||||||
|
|
||||||
/*let cache_dir =
|
/*let cache_dir =
|
||||||
xdg::BaseDirectories::with_profile("meli", format!("{}_Thread", folder.hash()))
|
xdg::BaseDirectories::with_profile("meli", format!("{}_Thread", folder.hash()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if let Some(cached) = cache_dir.find_cache_file("threads") {
|
if let Some(cached) = cache_dir.find_cache_file("threads") {
|
||||||
let reader = io::BufReader::new(fs::File::open(cached).unwrap());
|
let reader = io::BufReader::new(fs::File::open(cached).unwrap());
|
||||||
let result: result::Result<Threads, _> = bincode::deserialize_from(reader);
|
let result: result::Result<Threads, _> = bincode::deserialize_from(reader);
|
||||||
let ret = if let Ok(mut cached_t) = result {
|
let ret = if let Ok(mut cached_t) = result {
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
if cfg!(debug_assertions) {
|
debug!("loaded cache, our hash set is {:?}\n and the cached one is {:?}", FnvHashSet::from_iter(envelopes.keys().cloned()), cached_t.hash_set);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
cached_t.amend(&mut envelopes);
|
||||||
eprintln!("loaded cache, our hash set is {:?}\n and the cached one is {:?}", FnvHashSet::from_iter(envelopes.keys().cloned()), cached_t.hash_set);
|
cached_t
|
||||||
}
|
} else {
|
||||||
cached_t.amend(&mut envelopes);
|
Threads::new(&mut envelopes)
|
||||||
cached_t
|
};
|
||||||
} else {
|
ret
|
||||||
Threads::new(&mut envelopes)
|
} else {
|
||||||
};
|
Threads::new(&mut envelopes)
|
||||||
ret
|
};
|
||||||
} else {
|
*/
|
||||||
Threads::new(&mut envelopes)
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
Collection {
|
Collection {
|
||||||
folder: folder.clone(),
|
folder: folder.clone(),
|
||||||
|
@ -92,10 +89,7 @@ eprintln!("loaded cache, our hash set is {:?}\n and the cached one is {:?}", Fnv
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove(&mut self, envelope_hash: EnvelopeHash) {
|
pub fn remove(&mut self, envelope_hash: EnvelopeHash) {
|
||||||
if cfg!(debug_assertions) {
|
debug!("DEBUG: Removing {}", envelope_hash);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("DEBUG: Removing {}", envelope_hash);
|
|
||||||
}
|
|
||||||
self.envelopes.remove(&envelope_hash);
|
self.envelopes.remove(&envelope_hash);
|
||||||
self.threads.remove(envelope_hash, &mut self.envelopes);
|
self.threads.remove(envelope_hash, &mut self.envelopes);
|
||||||
}
|
}
|
||||||
|
@ -145,10 +139,7 @@ eprintln!("DEBUG: Removing {}", envelope_hash);
|
||||||
|
|
||||||
pub fn insert(&mut self, envelope: Envelope) {
|
pub fn insert(&mut self, envelope: Envelope) {
|
||||||
let hash = envelope.hash();
|
let hash = envelope.hash();
|
||||||
if cfg!(debug_assertions) {
|
debug!("DEBUG: Inserting hash {} in {}", hash, self.folder.name());
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("DEBUG: Inserting hash {} in {}", hash, self.folder.name());
|
|
||||||
}
|
|
||||||
self.envelopes.insert(hash, envelope);
|
self.envelopes.insert(hash, envelope);
|
||||||
let env = self.envelopes.entry(hash).or_default() as *mut Envelope;
|
let env = self.envelopes.entry(hash).or_default() as *mut Envelope;
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -158,13 +149,10 @@ eprintln!("DEBUG: Inserting hash {} in {}", hash, self.folder.name());
|
||||||
pub(crate) fn insert_reply(&mut self, _envelope: &Envelope) {
|
pub(crate) fn insert_reply(&mut self, _envelope: &Envelope) {
|
||||||
return;
|
return;
|
||||||
/*
|
/*
|
||||||
//self.insert(envelope);
|
//self.insert(envelope);
|
||||||
if cfg!(debug_assertions) {
|
debug!("insert_reply in collections");
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
self.threads.insert_reply(envelope, &mut self.envelopes);
|
||||||
eprintln!("insert_reply in collections");
|
*/
|
||||||
}
|
|
||||||
self.threads.insert_reply(envelope, &mut self.envelopes);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -394,10 +394,7 @@ impl Envelope {
|
||||||
let (headers, _) = match parser::mail(bytes).to_full_result() {
|
let (headers, _) = match parser::mail(bytes).to_full_result() {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("error in parsing mail\n{:?}\n", e);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("error in parsing mail\n{:?}\n", e);
|
|
||||||
}
|
|
||||||
let error_msg = String::from("Mail cannot be shown because of errors.");
|
let error_msg = String::from("Mail cannot be shown because of errors.");
|
||||||
return Err(MeliError::new(error_msg));
|
return Err(MeliError::new(error_msg));
|
||||||
}
|
}
|
||||||
|
@ -550,10 +547,7 @@ eprintln!("error in parsing mail\n{:?}\n", e);
|
||||||
let (headers, body) = match parser::mail(bytes).to_full_result() {
|
let (headers, body) = match parser::mail(bytes).to_full_result() {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("error in parsing mail\n");
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("error in parsing mail\n");
|
|
||||||
}
|
|
||||||
let error_msg = b"Mail cannot be shown because of errors.";
|
let error_msg = b"Mail cannot be shown because of errors.";
|
||||||
let builder = AttachmentBuilder::new(error_msg);
|
let builder = AttachmentBuilder::new(error_msg);
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
@ -584,36 +578,32 @@ eprintln!("error in parsing mail\n");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn body(&self, mut operation: Box<BackendOp>) -> Attachment {
|
pub fn body(&self, mut operation: Box<BackendOp>) -> Attachment {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("searching body for {:?}", self.message_id_display());
|
||||||
eprintln!("searching body for {:?}", self.message_id_display());
|
|
||||||
let file = operation.as_bytes();
|
let file = operation.as_bytes();
|
||||||
self.body_bytes(file.unwrap())
|
self.body_bytes(file.unwrap())
|
||||||
/*
|
/*
|
||||||
let (headers, body) = match parser::mail(file.unwrap()).to_full_result() {
|
let (headers, body) = match parser::mail(file.unwrap()).to_full_result() {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("2error in parsing mail\n");
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
let error_msg = b"Mail cannot be shown because of errors.";
|
||||||
eprintln!("2error in parsing mail\n");
|
let mut builder = AttachmentBuilder::new(error_msg);
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let mut builder = AttachmentBuilder::new(body);
|
||||||
|
for (name, value) in headers {
|
||||||
|
if value.len() == 1 && value.is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if name.eq_ignore_ascii_case(b"content-transfer-encoding") {
|
||||||
|
builder.content_transfer_encoding(value);
|
||||||
|
} else if name.eq_ignore_ascii_case(b"content-type") {
|
||||||
|
builder.content_type(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let error_msg = b"Mail cannot be shown because of errors.";
|
builder.build()
|
||||||
let mut builder = AttachmentBuilder::new(error_msg);
|
*/
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let mut builder = AttachmentBuilder::new(body);
|
|
||||||
for (name, value) in headers {
|
|
||||||
if value.len() == 1 && value.is_empty() {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if name.eq_ignore_ascii_case(b"content-transfer-encoding") {
|
|
||||||
builder.content_transfer_encoding(value);
|
|
||||||
} else if name.eq_ignore_ascii_case(b"content-type") {
|
|
||||||
builder.content_type(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
builder.build()
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
pub fn subject(&self) -> Cow<str> {
|
pub fn subject(&self) -> Cow<str> {
|
||||||
match self.subject {
|
match self.subject {
|
||||||
|
|
|
@ -68,10 +68,7 @@ impl<'a> From<&'a [u8]> for Charset {
|
||||||
b"BIG5" | b"big5" => Charset::BIG5,
|
b"BIG5" | b"big5" => Charset::BIG5,
|
||||||
b"ISO-2022-JP" | b"iso-2022-JP" => Charset::ISO2022JP,
|
b"ISO-2022-JP" | b"iso-2022-JP" => Charset::ISO2022JP,
|
||||||
_ => {
|
_ => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("unknown tag is {:?}", str::from_utf8(b));
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("unknown tag is {:?}", str::from_utf8(b));
|
|
||||||
}
|
|
||||||
Charset::Ascii
|
Charset::Ascii
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,10 +143,7 @@ impl AttachmentBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(v) => {
|
Err(v) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("parsing error in content_type: {:?} {:?}", value, v);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("parsing error in content_type: {:?} {:?}", value, v);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
|
@ -212,22 +209,10 @@ eprintln!("parsing error in content_type: {:?} {:?}", value, v);
|
||||||
let (headers, body) = match parser::attachment(&a).to_full_result() {
|
let (headers, body) = match parser::attachment(&a).to_full_result() {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("error in parsing attachment");
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("\n-------------------------------");
|
||||||
eprintln!("error in parsing attachment");
|
debug!("{}\n", ::std::string::String::from_utf8_lossy(a));
|
||||||
}
|
debug!("-------------------------------\n");
|
||||||
if cfg!(debug_assertions) {
|
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("\n-------------------------------");
|
|
||||||
}
|
|
||||||
if cfg!(debug_assertions) {
|
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("{}\n", ::std::string::String::from_utf8_lossy(a));
|
|
||||||
}
|
|
||||||
if cfg!(debug_assertions) {
|
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("-------------------------------\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -250,8 +235,7 @@ eprintln!("-------------------------------\n");
|
||||||
vec
|
vec
|
||||||
}
|
}
|
||||||
a => {
|
a => {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!(
|
||||||
eprintln!(
|
|
||||||
"error {:?}\n\traw: {:?}\n\tboundary: {:?}",
|
"error {:?}\n\traw: {:?}\n\tboundary: {:?}",
|
||||||
a,
|
a,
|
||||||
str::from_utf8(raw).unwrap(),
|
str::from_utf8(raw).unwrap(),
|
||||||
|
@ -400,24 +384,18 @@ fn decode_rfc822(_raw: &[u8]) -> Attachment {
|
||||||
builder.build()
|
builder.build()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if cfg!(debug_assertions) {
|
debug!("raw is\n{:?}", str::from_utf8(raw).unwrap());
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
let e = match Envelope::from_bytes(raw) {
|
||||||
eprintln!("raw is\n{:?}", str::from_utf8(raw).unwrap());
|
Some(e) => e,
|
||||||
}
|
None => {
|
||||||
let e = match Envelope::from_bytes(raw) {
|
debug!("error in parsing mail");
|
||||||
Some(e) => e,
|
let error_msg = b"Mail cannot be shown because of errors.";
|
||||||
None => {
|
let mut builder = AttachmentBuilder::new(error_msg);
|
||||||
if cfg!(debug_assertions) {
|
return builder.build();
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
}
|
||||||
eprintln!("error in parsing mail");
|
};
|
||||||
}
|
e.body(None)
|
||||||
let error_msg = b"Mail cannot be shown because of errors.";
|
*/
|
||||||
let mut builder = AttachmentBuilder::new(error_msg);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
e.body(None)
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Filter<'a> = Box<FnMut(&'a Attachment, &mut Vec<u8>) -> () + 'a>;
|
type Filter<'a> = Box<FnMut(&'a Attachment, &mut Vec<u8>) -> () + 'a>;
|
||||||
|
|
|
@ -766,14 +766,8 @@ mod tests {
|
||||||
let s = b"Thu, 31 Aug 2017 13:43:37 +0000 (UTC)";
|
let s = b"Thu, 31 Aug 2017 13:43:37 +0000 (UTC)";
|
||||||
let _s = b"Thu, 31 Aug 2017 13:43:37 +0000";
|
let _s = b"Thu, 31 Aug 2017 13:43:37 +0000";
|
||||||
let __s = b"=?utf-8?q?Thu=2C_31_Aug_2017_13=3A43=3A37_-0000?=";
|
let __s = b"=?utf-8?q?Thu=2C_31_Aug_2017_13=3A43=3A37_-0000?=";
|
||||||
if cfg!(debug_assertions) {
|
debug!("{:?}, {:?}", date(s), date(_s));
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("{:?}", date(__s));
|
||||||
eprintln!("{:?}, {:?}", date(s), date(_s));
|
|
||||||
}
|
|
||||||
if cfg!(debug_assertions) {
|
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("{:?}", date(__s));
|
|
||||||
}
|
|
||||||
assert_eq!(date(s).unwrap(), date(_s).unwrap());
|
assert_eq!(date(s).unwrap(), date(_s).unwrap());
|
||||||
assert_eq!(date(_s).unwrap(), date(__s).unwrap());
|
assert_eq!(date(_s).unwrap(), date(__s).unwrap());
|
||||||
}
|
}
|
||||||
|
|
|
@ -574,36 +574,25 @@ impl Threads {
|
||||||
|
|
||||||
t.create_root_set(collection);
|
t.create_root_set(collection);
|
||||||
t.build_collection(collection);
|
t.build_collection(collection);
|
||||||
//if cfg!(debug_assertions) {
|
// for (i, _t) in t.thread_nodes.iter().enumerate() {
|
||||||
// for (i, _t) in t.thread_nodes.iter().enumerate() {
|
// debug!("Thread #{}, children {}", i, _t.children.len());
|
||||||
// eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
// if !_t.children.is_empty() {
|
||||||
// eprintln!("Thread #{}, children {}", i, _t.children.len());
|
// debug!("{:?}", _t.children);
|
||||||
// if !_t.children.is_empty() {
|
// }
|
||||||
// eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
// if let Some(m) = _t.message {
|
||||||
// eprintln!("{:?}", _t.children);
|
// debug!("\tmessage: {}", collection[&m].subject());
|
||||||
// }
|
// } else {
|
||||||
// if let Some(m) = _t.message {
|
// debug!("\tNo message");
|
||||||
// eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
// }
|
||||||
// eprintln!("\tmessage: {}", collection[&m].subject());
|
// }
|
||||||
// } else {
|
// for (i, _t) in t.tree.borrow().iter().enumerate() {
|
||||||
// eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
// debug!("Tree #{} id {}, children {}", i, _t.id, _t.children.len());
|
||||||
// eprintln!("\tNo message");
|
// if let Some(m) = t.thread_nodes[_t.id].message {
|
||||||
// }
|
// debug!("\tmessage: {}", collection[&m].subject());
|
||||||
// }
|
// } else {
|
||||||
// eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
// debug!("\tNo message");
|
||||||
//eprintln!("\n");
|
// }
|
||||||
// for (i, _t) in t.tree.borrow().iter().enumerate() {
|
// }
|
||||||
// eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
//eprintln!("Tree #{} id {}, children {}", i, _t.id, _t.children.len());
|
|
||||||
// if let Some(m) = t.thread_nodes[_t.id].message {
|
|
||||||
// eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
//eprintln!("\tmessage: {}", collection[&m].subject());
|
|
||||||
// } else {
|
|
||||||
// eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
//eprintln!("\tNo message");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
t
|
t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -847,10 +836,7 @@ impl Threads {
|
||||||
// .iter()
|
// .iter()
|
||||||
// .position(|n| n.message.map(|n| n == envelope_hash).unwrap_or(false))
|
// .position(|n| n.message.map(|n| n == envelope_hash).unwrap_or(false))
|
||||||
// .unwrap();
|
// .unwrap();
|
||||||
// if cfg!(debug_assertions) {
|
// debug!("DEBUG: {} in threads is idx= {}", envelope_hash, pos);
|
||||||
// eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
// eprintln!("DEBUG: {} in threads is idx= {}", envelope_hash, pos);
|
|
||||||
// }
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
let t_id: usize;
|
let t_id: usize;
|
||||||
|
@ -909,10 +895,7 @@ impl Threads {
|
||||||
let difference: Vec<EnvelopeHash> =
|
let difference: Vec<EnvelopeHash> =
|
||||||
new_hash_set.difference(&self.hash_set).cloned().collect();
|
new_hash_set.difference(&self.hash_set).cloned().collect();
|
||||||
for h in difference {
|
for h in difference {
|
||||||
if cfg!(debug_assertions) {
|
debug!("inserting {}", collection[&h].subject());
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("inserting {}", collection[&h].subject());
|
|
||||||
}
|
|
||||||
let env = collection.entry(h).or_default() as *mut Envelope;
|
let env = collection.entry(h).or_default() as *mut Envelope;
|
||||||
unsafe {
|
unsafe {
|
||||||
// `collection` is borrowed immutably and `insert` only changes the envelope's
|
// `collection` is borrowed immutably and `insert` only changes the envelope's
|
||||||
|
|
|
@ -92,7 +92,7 @@ fn main() {
|
||||||
/* Poll on all channels. Currently we have the input channel for stdin, watching events and the signal watcher. */
|
/* Poll on all channels. Currently we have the input channel for stdin, watching events and the signal watcher. */
|
||||||
chan_select! {
|
chan_select! {
|
||||||
receiver.recv() -> r => {
|
receiver.recv() -> r => {
|
||||||
match r.unwrap() {
|
match std::dbg!(r.unwrap()) {
|
||||||
ThreadEvent::Input(Key::Ctrl('z')) => {
|
ThreadEvent::Input(Key::Ctrl('z')) => {
|
||||||
state.switch_to_main_screen();
|
state.switch_to_main_screen();
|
||||||
//_thread_handler.join().expect("Couldn't join on the associated thread");
|
//_thread_handler.join().expect("Couldn't join on the associated thread");
|
||||||
|
|
|
@ -89,8 +89,6 @@ impl ContactList {
|
||||||
maxima.1 = std::cmp::max(maxima.1, c.lastname().split_graphemes().len());
|
maxima.1 = std::cmp::max(maxima.1, c.lastname().split_graphemes().len());
|
||||||
maxima.2 = std::cmp::max(maxima.2, c.email().split_graphemes().len());
|
maxima.2 = std::cmp::max(maxima.2, c.email().split_graphemes().len());
|
||||||
maxima.3 = std::cmp::max(maxima.3, c.url().split_graphemes().len());
|
maxima.3 = std::cmp::max(maxima.3, c.url().split_graphemes().len());
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("card = {:?}", c);
|
|
||||||
}
|
}
|
||||||
maxima.0 += 5;
|
maxima.0 += 5;
|
||||||
maxima.1 += maxima.0 + 5;
|
maxima.1 += maxima.0 + 5;
|
||||||
|
|
|
@ -501,10 +501,7 @@ impl Component for Composer {
|
||||||
let account = &context.accounts[self.account_cursor];
|
let account = &context.accounts[self.account_cursor];
|
||||||
let draft = std::mem::replace(&mut self.draft, Draft::default());
|
let draft = std::mem::replace(&mut self.draft, Draft::default());
|
||||||
if let Err(e) = account.save_draft(draft) {
|
if let Err(e) = account.save_draft(draft) {
|
||||||
if cfg!(debug_assertions) {
|
debug!("{:?} could not save draft", e);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("{:?} could not save draft", e);
|
|
||||||
}
|
|
||||||
context.replies.push_back(UIEvent::Notification(
|
context.replies.push_back(UIEvent::Notification(
|
||||||
Some("Could not save draft.".into()),
|
Some("Could not save draft.".into()),
|
||||||
e.into(),
|
e.into(),
|
||||||
|
@ -559,10 +556,7 @@ impl Component for Composer {
|
||||||
.conf()
|
.conf()
|
||||||
.sent_folder(),
|
.sent_folder(),
|
||||||
) {
|
) {
|
||||||
if cfg!(debug_assertions) {
|
debug!("{:?} could not save sent msg", e);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("{:?} could not save sent msg", e);
|
|
||||||
}
|
|
||||||
context.replies.push_back(UIEvent::Notification(
|
context.replies.push_back(UIEvent::Notification(
|
||||||
Some("Could not save in 'Sent' folder.".into()),
|
Some("Could not save in 'Sent' folder.".into()),
|
||||||
e.into(),
|
e.into(),
|
||||||
|
|
|
@ -470,9 +470,8 @@ impl Listing {
|
||||||
a: &AccountMenuEntry,
|
a: &AccountMenuEntry,
|
||||||
context: &mut Context,
|
context: &mut Context,
|
||||||
) -> usize {
|
) -> usize {
|
||||||
if cfg!(debug_assertions) && !is_valid_area!(area) {
|
if !is_valid_area!(area) {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("BUG: invalid area in print_account");
|
||||||
eprintln!("BUG: invalid area in print_account");
|
|
||||||
}
|
}
|
||||||
// Each entry and its index in the account
|
// Each entry and its index in the account
|
||||||
let entries: FnvHashMap<FolderHash, Folder> = context.accounts[a.index]
|
let entries: FnvHashMap<FolderHash, Folder> = context.accounts[a.index]
|
||||||
|
|
|
@ -166,20 +166,13 @@ impl MailboxView {
|
||||||
threads.thread_nodes()[iter_ptr].message().unwrap()
|
threads.thread_nodes()[iter_ptr].message().unwrap()
|
||||||
};
|
};
|
||||||
if !mailbox.collection.contains_key(&i) {
|
if !mailbox.collection.contains_key(&i) {
|
||||||
if cfg!(debug_assertions) {
|
debug!("key = {}", i);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!(
|
||||||
eprintln!("key = {}", i);
|
|
||||||
}
|
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!(
|
|
||||||
"name = {} {}",
|
"name = {} {}",
|
||||||
mailbox.name(),
|
mailbox.name(),
|
||||||
context.accounts[self.cursor_pos.0].name()
|
context.accounts[self.cursor_pos.0].name()
|
||||||
);
|
);
|
||||||
if cfg!(debug_assertions) {
|
debug!("{:#?}", context.accounts);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("{:#?}", context.accounts);
|
|
||||||
}
|
|
||||||
|
|
||||||
panic!();
|
panic!();
|
||||||
}
|
}
|
||||||
|
@ -506,19 +499,13 @@ impl Component for MailboxView {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Action::SubSort(field, order) => {
|
Action::SubSort(field, order) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("SubSort {:?} , {:?}", field, order);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("SubSort {:?} , {:?}", field, order);
|
|
||||||
}
|
|
||||||
self.subsort = (*field, *order);
|
self.subsort = (*field, *order);
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Action::Sort(field, order) => {
|
Action::Sort(field, order) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("Sort {:?} , {:?}", field, order);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("Sort {:?} , {:?}", field, order);
|
|
||||||
}
|
|
||||||
self.sort = (*field, *order);
|
self.sort = (*field, *order);
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
return true;
|
return true;
|
||||||
|
@ -643,8 +630,7 @@ impl CompactListing {
|
||||||
impl Component for CompactListing {
|
impl Component for CompactListing {
|
||||||
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||||
if !self.populated {
|
if !self.populated {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!("populating");
|
||||||
eprintln!("populating");
|
|
||||||
for (idx, a) in context.accounts.iter().enumerate() {
|
for (idx, a) in context.accounts.iter().enumerate() {
|
||||||
for (fidx, _) in a.iter_mailboxes().enumerate() {
|
for (fidx, _) in a.iter_mailboxes().enumerate() {
|
||||||
let mut m = MailboxView::new();
|
let mut m = MailboxView::new();
|
||||||
|
|
|
@ -160,20 +160,13 @@ impl MailboxView {
|
||||||
threads.thread_nodes()[iter_ptr].message().unwrap()
|
threads.thread_nodes()[iter_ptr].message().unwrap()
|
||||||
};
|
};
|
||||||
if !mailbox.collection.contains_key(&i) {
|
if !mailbox.collection.contains_key(&i) {
|
||||||
if cfg!(debug_assertions) {
|
debug!("key = {}", i);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!(
|
||||||
eprintln!("key = {}", i);
|
|
||||||
}
|
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!(
|
|
||||||
"name = {} {}",
|
"name = {} {}",
|
||||||
mailbox.name(),
|
mailbox.name(),
|
||||||
context.accounts[self.cursor_pos.0].name()
|
context.accounts[self.cursor_pos.0].name()
|
||||||
);
|
);
|
||||||
if cfg!(debug_assertions) {
|
debug!("{:#?}", context.accounts);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("{:#?}", context.accounts);
|
|
||||||
}
|
|
||||||
|
|
||||||
panic!();
|
panic!();
|
||||||
}
|
}
|
||||||
|
@ -462,19 +455,13 @@ impl Component for MailboxView {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Action::SubSort(field, order) => {
|
Action::SubSort(field, order) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("SubSort {:?} , {:?}", field, order);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("SubSort {:?} , {:?}", field, order);
|
|
||||||
}
|
|
||||||
self.subsort = (*field, *order);
|
self.subsort = (*field, *order);
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Action::Sort(field, order) => {
|
Action::Sort(field, order) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("Sort {:?} , {:?}", field, order);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("Sort {:?} , {:?}", field, order);
|
|
||||||
}
|
|
||||||
self.sort = (*field, *order);
|
self.sort = (*field, *order);
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -477,20 +477,14 @@ impl Component for PlainListing {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Action::SubSort(field, order) => {
|
Action::SubSort(field, order) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("SubSort {:?} , {:?}", field, order);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("SubSort {:?} , {:?}", field, order);
|
|
||||||
}
|
|
||||||
self.subsort = (*field, *order);
|
self.subsort = (*field, *order);
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Action::Sort(field, order) => {
|
Action::Sort(field, order) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("Sort {:?} , {:?}", field, order);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("Sort {:?} , {:?}", field, order);
|
|
||||||
}
|
|
||||||
self.sort = (*field, *order);
|
self.sort = (*field, *order);
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
|
|
|
@ -489,10 +489,7 @@ impl Component for ThreadListing {
|
||||||
let account = &mut context.accounts[self.cursor_pos.0];
|
let account = &mut context.accounts[self.cursor_pos.0];
|
||||||
let (hash, is_seen) = {
|
let (hash, is_seen) = {
|
||||||
let mailbox = &mut account[self.cursor_pos.1].as_mut().unwrap();
|
let mailbox = &mut account[self.cursor_pos.1].as_mut().unwrap();
|
||||||
if cfg!(debug_assertions) {
|
debug!("key is {}", self.locations[dbg!(self.cursor_pos).2]);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("key is {}", self.locations[dbg!(self.cursor_pos).2]);
|
|
||||||
}
|
|
||||||
let envelope: &Envelope =
|
let envelope: &Envelope =
|
||||||
&mailbox.collection[&self.locations[self.cursor_pos.2]];
|
&mailbox.collection[&self.locations[self.cursor_pos.2]];
|
||||||
(envelope.hash(), envelope.is_seen())
|
(envelope.hash(), envelope.is_seen())
|
||||||
|
@ -642,20 +639,14 @@ impl Component for ThreadListing {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Action::SubSort(field, order) => {
|
Action::SubSort(field, order) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("SubSort {:?} , {:?}", field, order);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("SubSort {:?} , {:?}", field, order);
|
|
||||||
}
|
|
||||||
self.subsort = (*field, *order);
|
self.subsort = (*field, *order);
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Action::Sort(field, order) => {
|
Action::Sort(field, order) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("Sort {:?} , {:?}", field, order);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("Sort {:?} , {:?}", field, order);
|
|
||||||
}
|
|
||||||
self.sort = (*field, *order);
|
self.sort = (*field, *order);
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
|
|
|
@ -832,14 +832,11 @@ impl Component for ThreadView {
|
||||||
let op = context.accounts[self.coordinates.0]
|
let op = context.accounts[self.coordinates.0]
|
||||||
.backend
|
.backend
|
||||||
.operation(envelope.hash(), mailbox.folder.hash());
|
.operation(envelope.hash(), mailbox.folder.hash());
|
||||||
if cfg!(debug_assertions) {
|
debug!(
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
"sending action edit for {}, {}",
|
||||||
eprintln!(
|
envelope.message_id(),
|
||||||
"sending action edit for {}, {}",
|
op.description()
|
||||||
envelope.message_id(),
|
);
|
||||||
op.description()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
context.replies.push_back(UIEvent::Action(Tab(Edit(
|
context.replies.push_back(UIEvent::Action(Tab(Edit(
|
||||||
self.coordinates,
|
self.coordinates,
|
||||||
|
|
|
@ -130,10 +130,7 @@ impl Component for NotificationFilter {
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
{
|
{
|
||||||
if cfg!(debug_assertions) {
|
debug!("{:?}", v);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("{:?}", v);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1072,8 +1072,7 @@ impl Component for Tabbed {
|
||||||
self.set_dirty();
|
self.set_dirty();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!(
|
||||||
eprintln!(
|
|
||||||
"DEBUG: Child component with id {:?} not found.\nList: {:?}",
|
"DEBUG: Child component with id {:?} not found.\nList: {:?}",
|
||||||
id, self.children
|
id, self.children
|
||||||
);
|
);
|
||||||
|
|
|
@ -134,10 +134,7 @@ impl Account {
|
||||||
let notify_fn = Arc::new(notify_fn);
|
let notify_fn = Arc::new(notify_fn);
|
||||||
|
|
||||||
if let Some(folder_confs) = settings.conf().folders() {
|
if let Some(folder_confs) = settings.conf().folders() {
|
||||||
//if cfg!(debug_assertions) {
|
//debug!("folder renames: {:?}", folder_renames);
|
||||||
//eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
//eprintln!("folder renames: {:?}", folder_renames);
|
|
||||||
//}
|
|
||||||
for f in ref_folders.values_mut() {
|
for f in ref_folders.values_mut() {
|
||||||
if let Some(r) = folder_confs.get(&f.name().to_ascii_lowercase()) {
|
if let Some(r) = folder_confs.get(&f.name().to_ascii_lowercase()) {
|
||||||
if let Some(rename) = r.rename() {
|
if let Some(rename) = r.rename() {
|
||||||
|
@ -228,19 +225,13 @@ impl Account {
|
||||||
return Some(EnvelopeUpdate(old_hash));
|
return Some(EnvelopeUpdate(old_hash));
|
||||||
}
|
}
|
||||||
RefreshEventKind::Rename(old_hash, new_hash) => {
|
RefreshEventKind::Rename(old_hash, new_hash) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("rename {} to {}", old_hash, new_hash);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("rename {} to {}", old_hash, new_hash);
|
|
||||||
}
|
|
||||||
let mailbox = mailbox!(&folder_hash, self.folders);
|
let mailbox = mailbox!(&folder_hash, self.folders);
|
||||||
mailbox.rename(old_hash, new_hash);
|
mailbox.rename(old_hash, new_hash);
|
||||||
return Some(EnvelopeRename(mailbox.folder.hash(), old_hash, new_hash));
|
return Some(EnvelopeRename(mailbox.folder.hash(), old_hash, new_hash));
|
||||||
}
|
}
|
||||||
RefreshEventKind::Create(envelope) => {
|
RefreshEventKind::Create(envelope) => {
|
||||||
if cfg!(debug_assertions) {
|
debug!("create {}", envelope.hash());
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("create {}", envelope.hash());
|
|
||||||
}
|
|
||||||
let env: &Envelope = mailbox!(&folder_hash, self.folders).insert(*envelope);
|
let env: &Envelope = mailbox!(&folder_hash, self.folders).insert(*envelope);
|
||||||
let ref_folders: FnvHashMap<FolderHash, Folder> = self.backend.folders();
|
let ref_folders: FnvHashMap<FolderHash, Folder> = self.backend.folders();
|
||||||
return Some(Notification(
|
return Some(Notification(
|
||||||
|
@ -284,10 +275,7 @@ impl Account {
|
||||||
pub fn list_folders(&self) -> Vec<Folder> {
|
pub fn list_folders(&self) -> Vec<Folder> {
|
||||||
let mut folders = self.backend.folders();
|
let mut folders = self.backend.folders();
|
||||||
if let Some(folder_confs) = self.settings.conf().folders() {
|
if let Some(folder_confs) = self.settings.conf().folders() {
|
||||||
//if cfg!(debug_assertions) {
|
//debug!("folder renames: {:?}", folder_renames);
|
||||||
//eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
//eprintln!("folder renames: {:?}", folder_renames);
|
|
||||||
//}
|
|
||||||
for f in folders.values_mut() {
|
for f in folders.values_mut() {
|
||||||
if let Some(r) = folder_confs.get(&f.name().to_ascii_lowercase()) {
|
if let Some(r) = folder_confs.get(&f.name().to_ascii_lowercase()) {
|
||||||
if let Some(rename) = r.rename() {
|
if let Some(rename) = r.rename() {
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
* This library exports the public types and methods of its modules
|
* This library exports the public types and methods of its modules
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
extern crate melib;
|
extern crate melib;
|
||||||
extern crate mime_apps;
|
extern crate mime_apps;
|
||||||
extern crate notify_rust;
|
extern crate notify_rust;
|
||||||
|
|
|
@ -243,16 +243,10 @@ impl State {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
s.flush();
|
s.flush();
|
||||||
if cfg!(debug_assertions) {
|
debug!("inserting mailbox hashes:");
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("DEBUG: inserting mailbox hashes:");
|
|
||||||
}
|
|
||||||
for (x, account) in s.context.accounts.iter_mut().enumerate() {
|
for (x, account) in s.context.accounts.iter_mut().enumerate() {
|
||||||
for folder in account.backend.folders().values() {
|
for folder in account.backend.folders().values() {
|
||||||
if cfg!(debug_assertions) {
|
debug!("hash & folder: {:?} {}", folder.hash(), folder.name());
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("hash & folder: {:?} {}", folder.hash(), folder.name());
|
|
||||||
}
|
|
||||||
s.context.mailbox_hashes.insert(folder.hash(), x);
|
s.context.mailbox_hashes.insert(folder.hash(), x);
|
||||||
}
|
}
|
||||||
let sender = s.context.sender.clone();
|
let sender = s.context.sender.clone();
|
||||||
|
@ -293,8 +287,7 @@ impl State {
|
||||||
.replies
|
.replies
|
||||||
.push_back(UIEvent::MailboxUpdate((idxa, hash)));
|
.push_back(UIEvent::MailboxUpdate((idxa, hash)));
|
||||||
} else {
|
} else {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!(
|
||||||
eprintln!(
|
|
||||||
"BUG: mailbox with hash {} not found in mailbox_hashes.",
|
"BUG: mailbox with hash {} not found in mailbox_hashes.",
|
||||||
hash
|
hash
|
||||||
);
|
);
|
||||||
|
@ -355,8 +348,7 @@ impl State {
|
||||||
if termcols.unwrap_or(72) as usize != self.cols
|
if termcols.unwrap_or(72) as usize != self.cols
|
||||||
|| termrows.unwrap_or(120) as usize != self.rows
|
|| termrows.unwrap_or(120) as usize != self.rows
|
||||||
{
|
{
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!(
|
||||||
eprintln!(
|
|
||||||
"Size updated, from ({}, {}) -> ({:?}, {:?})",
|
"Size updated, from ({}, {}) -> ({:?}, {:?})",
|
||||||
self.cols, self.rows, termcols, termrows
|
self.cols, self.rows, termcols, termrows
|
||||||
);
|
);
|
||||||
|
|
|
@ -574,8 +574,7 @@ pub fn copy_area_with_break(
|
||||||
src: Area,
|
src: Area,
|
||||||
) -> Pos {
|
) -> Pos {
|
||||||
if !is_valid_area!(dest) || !is_valid_area!(src) {
|
if !is_valid_area!(dest) || !is_valid_area!(src) {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!(
|
||||||
eprintln!(
|
|
||||||
"BUG: Invalid areas in copy_area:\n src: {:?}\n dest: {:?}",
|
"BUG: Invalid areas in copy_area:\n src: {:?}\n dest: {:?}",
|
||||||
src, dest
|
src, dest
|
||||||
);
|
);
|
||||||
|
@ -622,8 +621,7 @@ pub fn copy_area_with_break(
|
||||||
/// Copy a source `Area` to a destination.
|
/// Copy a source `Area` to a destination.
|
||||||
pub fn copy_area(grid_dest: &mut CellBuffer, grid_src: &CellBuffer, dest: Area, src: Area) -> Pos {
|
pub fn copy_area(grid_dest: &mut CellBuffer, grid_src: &CellBuffer, dest: Area, src: Area) -> Pos {
|
||||||
if !is_valid_area!(dest) || !is_valid_area!(src) {
|
if !is_valid_area!(dest) || !is_valid_area!(src) {
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
debug!(
|
||||||
eprintln!(
|
|
||||||
"BUG: Invalid areas in copy_area:\n src: {:?}\n dest: {:?}",
|
"BUG: Invalid areas in copy_area:\n src: {:?}\n dest: {:?}",
|
||||||
src, dest
|
src, dest
|
||||||
);
|
);
|
||||||
|
@ -639,10 +637,7 @@ pub fn copy_area(grid_dest: &mut CellBuffer, grid_src: &CellBuffer, dest: Area,
|
||||||
let mut src_y = get_y(upper_left!(src));
|
let mut src_y = get_y(upper_left!(src));
|
||||||
let (cols, rows) = grid_src.size();
|
let (cols, rows) = grid_src.size();
|
||||||
if src_x >= cols || src_y >= rows {
|
if src_x >= cols || src_y >= rows {
|
||||||
if cfg!(debug_assertions) {
|
debug!("BUG: src area outside of grid_src in copy_area",);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("DEBUG: src area outside of grid_src in copy_area",);
|
|
||||||
}
|
|
||||||
return upper_left!(dest);
|
return upper_left!(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -679,17 +674,11 @@ pub fn change_colors(grid: &mut CellBuffer, area: Area, fg_color: Color, bg_colo
|
||||||
|| y >= get_y(bounds)
|
|| y >= get_y(bounds)
|
||||||
|| x >= get_x(bounds)
|
|| x >= get_x(bounds)
|
||||||
{
|
{
|
||||||
if cfg!(debug_assertions) {
|
debug!("BUG: Invalid area in change_colors:\n area: {:?}", area);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("BUG: Invalid area in change_colors:\n area: {:?}", area);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if !is_valid_area!(area) {
|
if !is_valid_area!(area) {
|
||||||
if cfg!(debug_assertions) {
|
debug!("BUG: Invalid area in change_colors:\n area: {:?}", area);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("BUG: Invalid area in change_colors:\n area: {:?}", area);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for y in get_y(upper_left!(area))..=get_y(bottom_right!(area)) {
|
for y in get_y(upper_left!(area))..=get_y(bottom_right!(area)) {
|
||||||
|
@ -739,10 +728,7 @@ pub fn write_string_to_grid(
|
||||||
|| y > get_y(bounds)
|
|| y > get_y(bounds)
|
||||||
|| x > get_x(bounds)
|
|| x > get_x(bounds)
|
||||||
{
|
{
|
||||||
if cfg!(debug_assertions) {
|
debug!(" Invalid area with string {} and area {:?}", s, area);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!(" Invalid area with string {} and area {:?}", s, area);
|
|
||||||
}
|
|
||||||
return (x, y);
|
return (x, y);
|
||||||
}
|
}
|
||||||
for c in s.chars() {
|
for c in s.chars() {
|
||||||
|
|
|
@ -228,10 +228,7 @@ impl WorkController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report the amount of work done.
|
// Report the amount of work done.
|
||||||
if cfg!(debug_assertions) {
|
debug!("Thread {} did {} jobs.", thread_num, work_done);
|
||||||
eprint!("{}:{}_{}: ", file!(), line!(), column!());
|
|
||||||
eprintln!("Thread {} did {} jobs.", thread_num, work_done);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add the handle for the newly spawned thread to the list of handles
|
// Add the handle for the newly spawned thread to the list of handles
|
||||||
|
|
Loading…
Reference in New Issue