summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-07-16 13:54:31 -0400
committerMason Reed <mason@vector35.com>2025-07-17 06:20:20 -0400
commit644f73061860086df6169031af8eecac0513aba5 (patch)
tree47b7503fc380afdac60217390f4935679be74465 /plugins
parent8111479952022384271358470229417933845077 (diff)
[WARP] Fix skipping warp files in projects
Diffstat (limited to 'plugins')
-rw-r--r--plugins/warp/src/plugin/project.rs22
-rw-r--r--plugins/warp/src/processor.rs21
2 files changed, 27 insertions, 16 deletions
diff --git a/plugins/warp/src/plugin/project.rs b/plugins/warp/src/plugin/project.rs
index 5047ad0c..56f1113a 100644
--- a/plugins/warp/src/plugin/project.rs
+++ b/plugins/warp/src/plugin/project.rs
@@ -115,6 +115,7 @@ impl CreateSignatures {
let report_kind = form.generated_report_kind();
let compression_type = form.compression_type();
let save_individual_files = form.save_individual_files();
+ let skip_existing_warp_files = form.skip_existing_warp_files();
// Save the warp file to the project.
let save_warp_file = move |project: &Project,
@@ -166,27 +167,16 @@ impl CreateSignatures {
let mut processor = WarpFileProcessor::new()
.with_file_data(file_data_kind)
- .with_compression_type(compression_type);
+ .with_compression_type(compression_type)
+ .with_skip_warp_files(skip_existing_warp_files);
if save_individual_files {
processor = processor.with_processed_file_callback(save_individual_files_cb);
}
- // Construct the user-supplied file filter, we also have an appended filter for warp files.
- let mut filter = form.file_filter();
- // This checkbox is here as this is very common to filter for.
- // And we want to do it by default.
- if form.skip_existing_warp_files() {
- let warp_filter = Regex::new(".*\\.warp").unwrap();
- filter = match filter {
- Some(existing) => {
- let combined = format!("{}|.*\\.warp", existing.as_str());
- Some(Regex::new(&combined).unwrap())
- }
- None => Some(warp_filter),
- };
- }
- if let Some(filter) = filter {
+ // Construct the user-supplied file filter. This will filter files in the project only, files
+ // in an archive will be considered a part of the archive file.
+ if let Some(filter) = form.file_filter() {
processor = processor.with_file_filter(filter);
}
diff --git a/plugins/warp/src/processor.rs b/plugins/warp/src/processor.rs
index 056b8a89..d3ccb300 100644
--- a/plugins/warp/src/processor.rs
+++ b/plugins/warp/src/processor.rs
@@ -67,6 +67,9 @@ pub enum ProcessingError {
#[error("Processing has been cancelled")]
Cancelled,
+
+ #[error("Skipping file: {0}")]
+ SkippedFile(PathBuf),
}
#[derive(Debug, Clone, Default)]
@@ -341,6 +344,9 @@ pub struct WarpFileProcessor {
processed_file_callback: Option<ProcessedFileCallback>,
/// Regex pattern used to filter out files.
file_filter: Option<Regex>,
+ // TODO: Merge with file filter.
+ /// Whether to skip processing warp files.
+ skip_warp_files: bool,
/// Processor state, this is shareable between threads, so the processor and the consumer can
/// read / write to the state, use this if you want to show a progress indicator.
state: Arc<ProcessingState>,
@@ -365,6 +371,7 @@ impl WarpFileProcessor {
compression_type: Default::default(),
processed_file_callback: None,
file_filter: None,
+ skip_warp_files: false,
state: Arc::new(ProcessingState::default()),
}
}
@@ -424,6 +431,11 @@ impl WarpFileProcessor {
}
}
+ pub fn with_skip_warp_files(mut self, skip: bool) -> Self {
+ self.skip_warp_files = skip;
+ self
+ }
+
/// Place a call to this in places to interrupt when canceled.
fn check_cancelled(&self) -> Result<(), ProcessingError> {
match self.state.is_cancelled() {
@@ -493,6 +505,10 @@ impl WarpFileProcessor {
.filter_map(|res| match res {
Ok(result) => Some(Ok(result)),
Err(ProcessingError::Cancelled) => Some(Err(ProcessingError::Cancelled)),
+ Err(ProcessingError::SkippedFile(path)) => {
+ log::debug!("Skipping project file: {:?}", path);
+ None
+ }
Err(e) => {
log::error!("Project file processing error: {:?}", e);
None
@@ -531,6 +547,11 @@ impl WarpFileProcessor {
}
pub fn process_warp_file(&self, path: PathBuf) -> Result<WarpFile<'static>, ProcessingError> {
+ // TODO: In the future this really should just be a file filter.
+ if self.skip_warp_files {
+ return Err(ProcessingError::SkippedFile(path));
+ }
+
let contents = std::fs::read(&path).map_err(ProcessingError::FileRead)?;
let file = WarpFile::from_owned_bytes(contents)
.ok_or(ProcessingError::ExistingDataLoad(path.clone()));