fix: remove assert to check cache format (#689)

* fix: remove assert

* rustmft
This commit is contained in:
Matthias Seitz 2021-12-14 00:37:35 +01:00 committed by GitHub
parent 3338cdead1
commit 4bb2636b77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 14 deletions

View File

@ -273,20 +273,14 @@ impl SolFilesCacheBuilder {
files.insert(file, entry);
}
let cache = if let Some(ref dest) = dest {
if dest.exists() {
// read the existing cache and extend it by the files that changed
// (if we just wrote to the cache file, we'd overwrite the existing data)
let reader = std::io::BufReader::new(
File::open(dest).map_err(|err| SolcError::io(err, dest))?,
);
let mut cache: SolFilesCache = serde_json::from_reader(reader)?;
assert_eq!(cache.format, format);
cache.files.extend(files);
cache
} else {
SolFilesCache { format, files }
}
let cache = if let Some(dest) = dest.as_ref().filter(|dest| dest.exists()) {
// read the existing cache and extend it by the files that changed
// (if we just wrote to the cache file, we'd overwrite the existing data)
let reader =
std::io::BufReader::new(File::open(dest).map_err(|err| SolcError::io(err, dest))?);
let mut cache: SolFilesCache = serde_json::from_reader(reader)?;
cache.files.extend(files);
cache
} else {
SolFilesCache { format, files }
};