~matthiasbeyer/maildir

7c6d23e225e4b80e93cd9f2a12eb5fbe1c8d3cc6 — Kartikaya Gupta 1 year, 5 months ago 8185892
We can advance the timestamp without actually sleeping
1 files changed, 2 insertions(+), 4 deletions(-)

M src/lib.rs
M src/lib.rs => src/lib.rs +2 -4
@@ 5,7 5,6 @@ use std::io::prelude::*;
use std::ops::Deref;
use std::os::unix::fs::MetadataExt;
use std::path::{Path, PathBuf};
use std::thread;
use std::time;

use mailparse::*;


@@ 451,11 450,10 @@ impl Maildir {
        // loop when conflicting filenames occur, as described at
        // http://www.courier-mta.org/maildir.html
        // this assumes that pid and hostname don't change.
        let mut ts;
        let mut ts = time::SystemTime::now().duration_since(time::UNIX_EPOCH)?;
        let mut tmppath = self.path.clone();
        tmppath.push("tmp");
        loop {
            ts = time::SystemTime::now().duration_since(time::UNIX_EPOCH)?;
            tmppath.push(format!(
                "{}.M{}P{}.{}",
                ts.as_secs(),


@@ 467,7 465,7 @@ impl Maildir {
                break;
            }
            tmppath.pop();
            thread::sleep(time::Duration::from_millis(10));
            ts += time::Duration::from_millis(10);
        }

        let mut file = std::fs::File::create(tmppath.to_owned())?;