Skip to content

Commit 086a27d

Browse files
authored
Fix atomicity of IconCache::get_png (#288)
If an error is returned, no inserts should be performed.
1 parent 1839bbd commit 086a27d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/processes/macos_icons.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ impl IconCache {
3030
let mut hasher = DefaultHasher::new();
3131
tiff.hash(&mut hasher);
3232
let tiff_hash = hasher.finish();
33-
e.insert(tiff_hash);
3433
let icon = match self.icons.entry(tiff_hash) {
3534
Entry::Occupied(e) => e.into_mut(),
3635
Entry::Vacant(e) => {
3736
let png = tiff_to_png(&tiff)?;
3837
e.insert(png)
3938
}
4039
};
40+
e.insert(tiff_hash);
4141
Ok(icon)
4242
}
4343
}

0 commit comments

Comments
 (0)