feat: create primary background file if it doesn't exist

This commit is contained in:
Nikita Podvirnyi 2024-06-17 15:07:12 +02:00
parent b529f3e7da
commit eb0f0eae02
No known key found for this signature in database
GPG key ID: 859D416E5142AFF3

View file

@ -64,16 +64,25 @@ pub fn download_background() -> anyhow::Result<()> {
let info = get_background_info()?;
let mut download_image = true;
if crate::BACKGROUND_FILE.exists() {
let hash = Md5::digest(std::fs::read(crate::BACKGROUND_FILE.as_path())?);
if format!("{:x}", hash).to_lowercase() == info.hash {
tracing::debug!("Background picture is already downloaded. Skipping");
download_image = false;
if crate::BACKGROUND_PRIMARY_FILE.exists() {
tracing::debug!("Background picture is already patched. Skipping");
return Ok(());
}
}
}
if download_image {
let mut downloader = Downloader::new(&info.uri)?;
downloader.continue_downloading = false;
@ -81,6 +90,7 @@ pub fn download_background() -> anyhow::Result<()> {
if let Err(err) = downloader.download(crate::BACKGROUND_FILE.as_path(), |_, _| {}) {
anyhow::bail!(err);
}
}
// Workaround for GTK weakness
if info.uri.ends_with(".webp") {