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,22 +64,32 @@ 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");
return Ok(());
download_image = false;
if crate::BACKGROUND_PRIMARY_FILE.exists() {
tracing::debug!("Background picture is already patched. Skipping");
return Ok(());
}
}
}
let mut downloader = Downloader::new(&info.uri)?;
if download_image {
let mut downloader = Downloader::new(&info.uri)?;
downloader.continue_downloading = false;
downloader.continue_downloading = false;
if let Err(err) = downloader.download(crate::BACKGROUND_FILE.as_path(), |_, _| {}) {
anyhow::bail!(err);
if let Err(err) = downloader.download(crate::BACKGROUND_FILE.as_path(), |_, _| {}) {
anyhow::bail!(err);
}
}
// Workaround for GTK weakness