fn rotate(&mut self) -> Result<()> {
        let path = Path::new(&self.settings.shared.pueue_directory);
        let path = path.join("log");

        // Get all log files in the directory with their respective system time.
        let mut entries: BTreeMap<SystemTime, PathBuf> = BTreeMap::new();
        let mut directory_list = fs::read_dir(path)?;
        while let Some(Ok(entry)) = directory_list.next() {
            let path = entry.path();

            let metadata = entry.metadata()?;
            let time = metadata.modified()?;
            entries.insert(time, path);
        }

        // Remove all files above the threshold.
        // Old files are removed first (implictly by the BTree order).
        let mut number_entries = entries.len();
        let mut iter = entries.iter();
        while number_entries > 10 {
            if let Some((_, path)) = iter.next() {
                fs::remove_file(path)?;
                number_entries -= 1;
            }
        }

        Ok(())
    }
/// Remove old logs that aren't needed any longer.
Remove old logs that aren't needed any longer.
Remove old logs that aren ' t needed any longer .
fn rotate(&mut self) -> Result<()> {
        let path = Path::new(&self.settings.shared.pueue_directory);
        let path = path.join("log");
        // Get all log files in the directory with their respective system time.
        let mut entries: BTreeMap<SystemTime, PathBuf> = BTreeMap::new();
        let mut directory_list = fs::read_dir(path)?;
        while let Some(Ok(entry)) = directory_list.next() {
            let path = entry.path();
            let metadata = entry.metadata()?;
            let time = metadata.modified()?;
            entries.insert(time, path);
        }
        // Remove all files above the threshold.
        // Old files are removed first (implictly by the BTree order).
        let mut number_entries = entries.len();
        let mut iter = entries.iter();
        while number_entries > 10 {
            if let Some((_, path)) = iter.next() {
                fs::remove_file(path)?;
                number_entries -= 1;
            }
        }
        Ok(())
    }
fn rotate ( & mut self ) -> Result < ( ) > { let path = Path :: new ( & self . settings . shared . pueue_directory ) ; let path = path . join ( " " ) ; // Get all log files in the directory with their respective system time. let mut entries : BTreeMap < SystemTime , PathBuf > = BTreeMap :: new ( ) ; let mut directory_list = fs :: read_dir ( path ) ? ; while let Some ( Ok ( entry ) ) = directory_list . next ( ) { let path = entry . path ( ) ; let metadata = entry . metadata ( ) ? ; let time = metadata . modified ( ) ? ; entries . insert ( time , path ) ; } // Remove all files above the threshold. // Old files are removed first (implictly by the BTree order). let mut number_entries = entries . len ( ) ; let mut iter = entries . iter ( ) ; while number_entries > 10 { if let Some ( ( _ , path ) ) = iter . next ( ) { fs :: remove_file ( path ) ? ; number_entries -= 1 ; } } Ok ( ( ) ) }
Remove old logs that aren't needed any longer.
Remove old logs that aren ' t needed any longer .
&mut self