summaryrefslogtreecommitdiffstats
path: root/melib/src
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-04-21 21:20:13 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-06-10 19:40:45 +0300
commit596194fa47420c912db9ea8b7b7d96ce4bf31280 (patch)
treec1bb6f0c2124e3442e54a34662b89e57c12549b2 /melib/src
parent8e06e298ab965ea99882f0550f0e140d49fb2e83 (diff)
melib: fix debug prints not debug-build only
Diffstat (limited to 'melib/src')
-rw-r--r--melib/src/mailbox/backends/maildir/backend.rs52
1 files changed, 38 insertions, 14 deletions
diff --git a/melib/src/mailbox/backends/maildir/backend.rs b/melib/src/mailbox/backends/maildir/backend.rs
index 878c40a5..9699a8bd 100644
--- a/melib/src/mailbox/backends/maildir/backend.rs
+++ b/melib/src/mailbox/backends/maildir/backend.rs
@@ -316,8 +316,10 @@ eprintln!("removed but not contained in index");
}
/* Envelope hasn't changed */
DebouncedEvent::Rename(src, dest) => {
- eprint!("{}:{}_{}: ", file!(), line!(), column!());
-eprintln!("DebouncedEvent::Rename(src = {:?}, dest = {:?})", src, dest);
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ eprintln!("DebouncedEvent::Rename(src = {:?}, dest = {:?})", src, dest);
+ }
let folder_hash = get_path_hash!(src);
let old_hash: EnvelopeHash = get_file_hash(src.as_path());
let new_hash: EnvelopeHash = get_file_hash(dest.as_path());
@@ -326,8 +328,10 @@ eprintln!("DebouncedEvent::Rename(src = {:?}, dest = {:?})", src, dest);
let index_lock = hash_indexes_lock.entry(folder_hash).or_default();
if index_lock.contains_key(&old_hash) {
- eprint!("{}:{}_{}: ", file!(), line!(), column!());
-eprintln!("contains_key");
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ eprintln!("contains_old_key");
+ }
sender.send(RefreshEvent {
hash: get_path_hash!(dest),
kind: Rename(old_hash, new_hash),
@@ -336,15 +340,19 @@ eprintln!("contains_key");
index_lock.insert(new_hash, dest);
continue;
} else if !index_lock.contains_key(&new_hash) {
- eprint!("{}:{}_{}: ", file!(), line!(), column!());
- eprintln!("not contains_key");
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ eprintln!("not contains_new_key");
+ }
let file_name = dest
.as_path()
.strip_prefix(&root_path)
.unwrap()
.to_path_buf();
- eprint!("{}:{}_{}: ", file!(), line!(), column!());
- eprintln!("filename = {:?}", file_name);
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ eprintln!("filename = {:?}", file_name);
+ }
if let Some(env) = add_path_to_index(
&hash_indexes,
folder_hash,
@@ -352,9 +360,9 @@ eprintln!("contains_key");
&cache_dir,
file_name,
) {
- eprint!("{}:{}_{}: ", file!(), line!(), column!());
- eprintln!("Create event {} {} {}", env.hash(), env.subject(), dest.display());
if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ eprintln!("Create event {} {} {}", env.hash(), env.subject(), dest.display());
}
sender.send(RefreshEvent {
hash: folder_hash,
@@ -362,15 +370,28 @@ eprintln!("contains_key");
});
continue;
} else {
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ eprintln!("not valid email");
+ }
+ }
+ } else {
+ sender.send(RefreshEvent {
+ hash: get_path_hash!(dest),
+ kind: Rename(old_hash, new_hash),
+ });
+ if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
- eprintln!("not valid email");
+ 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.
sender.send(RefreshEvent {
hash: get_path_hash!(dest),
kind: Rescan,
});
+ */
}
/* Trigger rescan of folder */
DebouncedEvent::Rescan => {
@@ -379,8 +400,11 @@ eprintln!("contains_key");
}
_ => {}
},
- Err(e) => {eprint!("{}:{}_{}: ", file!(), line!(), column!());
-eprintln!("watch error: {:?}", e)
+ Err(e) => {
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ eprintln!("watch error: {:?}", e)
+ }
}
}
}