mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2024-11-24 05:38:30 +03:00
feat: create primary background file if it doesn't exist
This commit is contained in:
parent
b529f3e7da
commit
eb0f0eae02
1 changed files with 15 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue