This commit is contained in:
Love 2023-03-06 13:57:49 +01:00
parent 6642978a0f
commit d1bfb69c0f

View File

@ -33,21 +33,20 @@ impl Playlist {
fs::metadata(&*self.path_to_playlist) fs::metadata(&*self.path_to_playlist)
.and_then(|metadata| { .and_then(|metadata| {
Ok({ Ok({
let seconds = metadata.modified()?; metadata
seconds .modified()?
.elapsed() .elapsed()
.expect("Failed to get systemtime") .map(|x| x.as_secs() > 60 * 60 * 24 * 3)
.as_secs() .unwrap_or_else(|_| {
> 60 * 60 * 24 * 3 println!("Could not get systemtime, trying to download new file");
true
})
}) })
}) })
.map_or_else( .unwrap_or_else(|_| {
|_| { println!("Could not find a saved playlist, Downloading a new one");
println!("Could not find playlist-file, Downloading a new one"); false
false })
},
|x| x,
)
} }
pub async fn get_saved_or_download(&self) -> Result<String, Error> { pub async fn get_saved_or_download(&self) -> Result<String, Error> {
@ -68,7 +67,7 @@ impl Playlist {
Ok(content) Ok(content)
} }
pub async fn download(&self) -> Result<String, Error> { pub async fn download(&self) -> Result<String, String> {
let mut counter: u8 = 0; let mut counter: u8 = 0;
loop { loop {
counter += 1; counter += 1;