You've already forked AstralRinth
forked from didirus/AstralRinth
fix all the red wiggly wiggles
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
use crate::data::DataError;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{data::DataError, LAUNCHER_WORK_DIR};
|
||||
use once_cell::sync;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::{RwLock, RwLockReadGuard};
|
||||
@@ -17,13 +19,11 @@ pub struct Metadata {
|
||||
|
||||
impl Metadata {
|
||||
pub async fn init() -> Result<(), DataError> {
|
||||
let meta_path = crate::LAUNCHER_WORK_DIR.join(META_FILE);
|
||||
let meta_path = Path::new(LAUNCHER_WORK_DIR).join(META_FILE);
|
||||
|
||||
if meta_path.exists() {
|
||||
let meta_data = std::fs::read_to_string(meta_path)
|
||||
.map(|x| serde_json::from_str::<Metadata>(&*x).ok())
|
||||
.ok()
|
||||
.flatten();
|
||||
let meta_data = std::fs::read_to_string(meta_path).ok()
|
||||
.and_then(|x| serde_json::from_str::<Metadata>(&x).ok());
|
||||
|
||||
if let Some(metadata) = meta_data {
|
||||
METADATA.get_or_init(|| RwLock::new(metadata));
|
||||
@@ -36,8 +36,8 @@ impl Metadata {
|
||||
let new = Self::fetch().await?;
|
||||
|
||||
std::fs::write(
|
||||
crate::LAUNCHER_WORK_DIR.join(META_FILE),
|
||||
&*serde_json::to_string(&new)?,
|
||||
Path::new(LAUNCHER_WORK_DIR).join(META_FILE),
|
||||
&serde_json::to_string(&new)?,
|
||||
)?;
|
||||
|
||||
if let Some(metadata) = METADATA.get() {
|
||||
|
||||
Reference in New Issue
Block a user