Browse Source

Move to yaml

master
Natsu Kagami 1 year ago
parent
commit
91c8ceb91c
2 changed files with 9 additions and 6 deletions
  1. +1
    -1
      .gitignore
  2. +8
    -5
      youmubot/src/db/mod.rs

+ 1
- 1
.gitignore View File

@@ -1,4 +1,4 @@
target
.env
*.toml
*.yaml
cargo-remote

+ 8
- 5
youmubot/src/db/mod.rs View File

@@ -27,7 +27,10 @@ where
{
fn insert_into(data: &mut ShareMap, path: impl AsRef<Path>) -> Result<(), Error> {
let db = FileDatabase::<T, Ron>::from_path(path, T::default())?;
db.load().or_else(|_| db.save())?;
db.load().or_else(|e| {
dbg!(e);
db.save()
})?;
data.insert::<DB<T>>(db);
Ok(())
}
@@ -52,10 +55,10 @@ pub fn setup_db(client: &mut Client) -> Result<(), Error> {
PathBuf::from("data")
});
let mut data = client.data.write();
SoftBans::insert_into(&mut *data, &path.join("soft_bans.toml"))?;
OsuSavedUsers::insert_into(&mut *data, &path.join("osu_saved_users.toml"))?;
OsuLastBeatmap::insert_into(&mut *data, &path.join("last_beatmaps.toml"))?;
AnnouncerChannels::insert_into(&mut *data, &path.join("announcers.toml"))?;
SoftBans::insert_into(&mut *data, &path.join("soft_bans.yaml"))?;
OsuSavedUsers::insert_into(&mut *data, &path.join("osu_saved_users.yaml"))?;
OsuLastBeatmap::insert_into(&mut *data, &path.join("last_beatmaps.yaml"))?;
AnnouncerChannels::insert_into(&mut *data, &path.join("announcers.yaml"))?;

Ok(())
}


Loading…
Cancel
Save