1+ use crate :: { settings:: rewrite:: Rewrite , utils:: generate_uuid:: generate_uuid} ;
12use chrono:: NaiveDateTime ;
23use diesel:: prelude:: * ;
34use serde:: Serialize ;
45use std:: fmt:: Display ;
56
6- use crate :: utils:: generate_uuid:: generate_uuid;
7-
87/// The status of a scan event being proccessed by [Targets](crate::service::targets).
98#[ derive( Serialize ) ]
109pub enum ProcessStatus {
@@ -16,7 +15,7 @@ pub enum ProcessStatus {
1615
1716/// Whether a file was found or not.
1817///
19- /// Note: only used if [opts.check_path](crate::settings::opts::Opts::check_path) is set.
18+ /// Note: only used if [` opts.check_path` ](crate::settings::opts::Opts::check_path) is set.
2019#[ derive( Serialize ) ]
2120pub enum FoundStatus {
2221 Found ,
@@ -79,7 +78,7 @@ pub struct ScanEvent {
7978 /// The status of the file being found.
8079 pub found_status : String ,
8180
82- /// The number of times the scan event has failed. Used for retries and is limited to [opts.max_retries](crate::settings::opts::Opts::max_retries).
81+ /// The number of times the scan event has failed. Used for retries and is limited to [` opts.max_retries` ](crate::settings::opts::Opts::max_retries).
8382 pub failed_times : i32 ,
8483 /// The time the scan event will be retried.
8584 pub next_retry_at : Option < chrono:: NaiveDateTime > ,
@@ -117,6 +116,13 @@ impl ScanEvent {
117116 targets. dedup ( ) ;
118117 self . targets_hit = targets. join ( "," ) ;
119118 }
119+
120+ pub fn get_path ( & self , rewrite : & Option < Rewrite > ) -> String {
121+ rewrite. as_ref ( ) . map_or_else (
122+ || self . file_path . clone ( ) ,
123+ |rewrite| rewrite. rewrite_path ( self . file_path . clone ( ) ) ,
124+ )
125+ }
120126}
121127
122128#[ derive( Insertable ) ]
0 commit comments