* Try to solve corpus issue related to #2981 * clippy
This commit is contained in:
parent
c53e51584b
commit
f9715392af
@ -362,7 +362,7 @@ impl<I> InMemoryOnDiskCorpus<I> {
|
|||||||
testcase.input().as_ref().unwrap().generate_name(id)
|
testcase.input().as_ref().unwrap().generate_name(id)
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut ctr = String::new();
|
let mut ctr = 1;
|
||||||
if self.locking {
|
if self.locking {
|
||||||
let lockfile_name = format!(".{file_name}");
|
let lockfile_name = format!(".{file_name}");
|
||||||
let lockfile_path = self.dir_path.join(lockfile_name);
|
let lockfile_path = self.dir_path.join(lockfile_name);
|
||||||
@ -375,15 +375,14 @@ impl<I> InMemoryOnDiskCorpus<I> {
|
|||||||
);
|
);
|
||||||
lockfile.lock_exclusive()?;
|
lockfile.lock_exclusive()?;
|
||||||
|
|
||||||
lockfile.read_to_string(&mut ctr)?;
|
let mut old_ctr = String::new();
|
||||||
ctr = if ctr.is_empty() {
|
lockfile.read_to_string(&mut old_ctr)?;
|
||||||
String::from("1")
|
if !old_ctr.is_empty() {
|
||||||
} else {
|
ctr = old_ctr.trim().parse::<u32>()? + 1;
|
||||||
(ctr.trim().parse::<u32>()? + 1).to_string()
|
}
|
||||||
};
|
|
||||||
|
|
||||||
lockfile.seek(SeekFrom::Start(0))?;
|
lockfile.seek(SeekFrom::Start(0))?;
|
||||||
lockfile.write_all(ctr.as_bytes())?;
|
lockfile.write_all(ctr.to_string().as_bytes())?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if testcase.file_path().is_none() {
|
if testcase.file_path().is_none() {
|
||||||
@ -432,11 +431,18 @@ impl<I> InMemoryOnDiskCorpus<I> {
|
|||||||
*testcase.metadata_path_mut() = Some(metafile_path);
|
*testcase.metadata_path_mut() = Some(metafile_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = self.store_input_from(testcase) {
|
// Only try to write the data if the counter is 1.
|
||||||
if self.locking {
|
// Otherwise we already have a file with this name, and
|
||||||
return Err(err);
|
// we can assume the data has already been written.
|
||||||
|
if ctr == 1 {
|
||||||
|
if let Err(err) = self.store_input_from(testcase) {
|
||||||
|
if self.locking {
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
|
log::error!(
|
||||||
|
"An error occurred when trying to write a testcase without locking: {err}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
log::error!("An error occurred when trying to write a testcase without locking: {err}");
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user