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