From 4bb2636b77d05084a98f5c049e15d1a0837a8024 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 14 Dec 2021 00:37:35 +0100 Subject: [PATCH] fix: remove assert to check cache format (#689) * fix: remove assert * rustmft --- ethers-solc/src/cache.rs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/ethers-solc/src/cache.rs b/ethers-solc/src/cache.rs index fb9fb908..fcf13ad3 100644 --- a/ethers-solc/src/cache.rs +++ b/ethers-solc/src/cache.rs @@ -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 } };