pub fn hash_been_rotated(&self) -> AppResult<bool> {
        // get most recent signature
        let old_signature = &self.id.signature;
        let new_signature = self.id.canon_path.signature(self.definition.hash_window)?;

        trace!(
            "file = {:?}, current signature = {:?}, recalculated = {:?}",
            &self.id.canon_path,
            old_signature,
            new_signature
        );

        // dev number are different: files are located in different file systems
        if old_signature.dev != new_signature.dev {
            Ok(true)
        }
        // dev are equal but inodes are different
        else if old_signature.inode != new_signature.inode {
            Ok(true)
        }
        // dev, inodes are equal => test hashes
        else {
            // if either hash is None (this means the file size is < hash_window) we can't decide
            if old_signature.hash.is_none() || new_signature.hash.is_none() {
                Err(AppError::new_custom(
                    AppCustomErrorKind::FileSizeIsLessThanHashWindow,
                    &format!(
                        "unable to determine a safe hash for logfile {:?}",
                        self.id.declared_path
                    ),
                ))
            }
            // if hashes are equal we can assume file has not been rotated
            else if old_signature.hash.unwrap() == new_signature.hash.unwrap() {
                Ok(false)
            }
            // if not we can assume this is a new file
            else {
                Ok(true)
            }
        }
    }
/// Recalculate the signature to check whether it has changed
Recalculate the signature to check whether it has changed
Recalculate the signature to check whether it has changed
pub fn hash_been_rotated(&self) -> AppResult<bool> {
        // get most recent signature
        let old_signature = &self.id.signature;
        let new_signature = self.id.canon_path.signature(self.definition.hash_window)?;
        trace!(
            "file = {:?}, current signature = {:?}, recalculated = {:?}",
            &self.id.canon_path,
            old_signature,
            new_signature
        );
        // dev number are different: files are located in different file systems
        if old_signature.dev != new_signature.dev {
            Ok(true)
        }
        // dev are equal but inodes are different
        else if old_signature.inode != new_signature.inode {
            Ok(true)
        }
        // dev, inodes are equal => test hashes
        else {
            // if either hash is None (this means the file size is < hash_window) we can't decide
            if old_signature.hash.is_none() || new_signature.hash.is_none() {
                Err(AppError::new_custom(
                    AppCustomErrorKind::FileSizeIsLessThanHashWindow,
                    &format!(
                        "unable to determine a safe hash for logfile {:?}",
                        self.id.declared_path
                    ),
                ))
            }
            // if hashes are equal we can assume file has not been rotated
            else if old_signature.hash.unwrap() == new_signature.hash.unwrap() {
                Ok(false)
            }
            // if not we can assume this is a new file
            else {
                Ok(true)
            }
        }
    }
pub fn hash_been_rotated ( & self ) -> AppResult < bool > { // get most recent signature let old_signature = & self . id . signature ; let new_signature = self . id . canon_path . signature ( self . definition . hash_window ) ? ; trace ! ( " " self id canon_path old_signature new_signature ) ; // dev number are different: files are located in different file systems if old_signature . dev != new_signature . dev { Ok ( true ) } // dev are equal but inodes are different else if old_signature . inode != new_signature . inode { Ok ( true ) } // dev, inodes are equal => test hashes else { // if either hash is None (this means the file size is < hash_window) we can't decide if old_signature . hash . is_none ( ) || new_signature . hash . is_none ( ) { Err ( AppError :: new_custom ( AppCustomErrorKind :: FileSizeIsLessThanHashWindow , & format ! ( " " self id declared_path ) , ) ) } // if hashes are equal we can assume file has not been rotated else if old_signature . hash . unwrap ( ) == new_signature . hash . unwrap ( ) { Ok ( false ) } // if not we can assume this is a new file else { Ok ( true ) } } }
Recalculate the signature to check whether it has changed
Recalculate the signature to check whether it has changed
&self
&self