mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Rename and recreate the default Anime config if cache setup fails
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
use std::path::Path;
|
||||
use std::time::Duration;
|
||||
|
||||
use log::error;
|
||||
|
||||
use crate::data::AnimeDataBuffer;
|
||||
use crate::error::{AnimeError, Result};
|
||||
use crate::AnimeType;
|
||||
@@ -49,7 +51,10 @@ impl AnimeDiagonal {
|
||||
bright: f32,
|
||||
anime_type: AnimeType,
|
||||
) -> Result<Self> {
|
||||
let data = std::fs::read(path)?;
|
||||
let data = std::fs::read(path).map_err(|e| {
|
||||
error!("Could not open {path:?}: {e:?}");
|
||||
e
|
||||
})?;
|
||||
let data = std::io::Cursor::new(data);
|
||||
let decoder = png_pong::Decoder::new(data)?.into_steps();
|
||||
let png_pong::Step { raster, delay: _ } = decoder.last().ok_or(AnimeError::NoFrames)??;
|
||||
|
||||
@@ -4,6 +4,7 @@ use std::path::Path;
|
||||
use std::time::Duration;
|
||||
|
||||
use glam::Vec2;
|
||||
use log::error;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use crate::error::{AnimeError, Result};
|
||||
@@ -107,7 +108,10 @@ impl AnimeGif {
|
||||
// Configure the decoder such that it will expand the image to RGBA.
|
||||
decoder.set_color_output(gif::ColorOutput::RGBA);
|
||||
// Read the file header
|
||||
let file = File::open(file_name)?;
|
||||
let file = File::open(file_name).map_err(|e| {
|
||||
error!("Could not open {file_name:?}: {e:?}");
|
||||
e
|
||||
})?;
|
||||
let mut decoder = decoder.read_info(file)?;
|
||||
|
||||
let mut frames = Vec::default();
|
||||
@@ -186,12 +190,14 @@ impl AnimeGif {
|
||||
anime_type: AnimeType,
|
||||
) -> Result<Self> {
|
||||
let mut frames = Vec::new();
|
||||
|
||||
let mut decoder = gif::DecodeOptions::new();
|
||||
// Configure the decoder such that it will expand the image to RGBA.
|
||||
decoder.set_color_output(gif::ColorOutput::RGBA);
|
||||
// Read the file header
|
||||
let file = File::open(file_name)?;
|
||||
let file = File::open(file_name).map_err(|e| {
|
||||
error!("Could not open {file_name:?}: {e:?}");
|
||||
e
|
||||
})?;
|
||||
let mut decoder = decoder.read_info(file)?;
|
||||
|
||||
let height = decoder.height();
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::path::Path;
|
||||
|
||||
pub use glam::Vec2;
|
||||
use glam::{Mat3, Vec3};
|
||||
use log::error;
|
||||
|
||||
use crate::data::AnimeDataBuffer;
|
||||
use crate::error::{AnimeError, Result};
|
||||
@@ -421,7 +422,10 @@ impl AnimeImage {
|
||||
bright: f32,
|
||||
anime_type: AnimeType,
|
||||
) -> Result<Self> {
|
||||
let data = std::fs::read(path)?;
|
||||
let data = std::fs::read(path).map_err(|e| {
|
||||
error!("Could not open {path:?}: {e:?}");
|
||||
e
|
||||
})?;
|
||||
let data = std::io::Cursor::new(data);
|
||||
let decoder = png_pong::Decoder::new(data)?.into_steps();
|
||||
let png_pong::Step { raster, delay: _ } = decoder.last().ok_or(AnimeError::NoFrames)??;
|
||||
|
||||
Reference in New Issue
Block a user