Create mod subdirectories for each game
This commit is contained in:
parent
14be03cd3d
commit
e96d760a1c
@ -11,8 +11,8 @@ mkdir -p plugins_data
|
|||||||
if [ -n "$last_update_time" ]; then
|
if [ -n "$last_update_time" ]; then
|
||||||
./target/release/mod-mapper -e cells/edits.json &>> logs/modmapper.log
|
./target/release/mod-mapper -e cells/edits.json &>> logs/modmapper.log
|
||||||
./target/release/mod-mapper -c cells &>> logs/modmapper.log
|
./target/release/mod-mapper -c cells &>> logs/modmapper.log
|
||||||
./target/release/mod-mapper -s mods/skyrimspecialedition_mod_search_index.json -g skyrimspecialedition &>> logs/modmapper.log
|
./target/release/mod-mapper -s mods/skyrimspecialedition/mod_search_index.json -g skyrimspecialedition &>> logs/modmapper.log
|
||||||
./target/release/mod-mapper -s mods/skyrim_mod_search_index.json -g skyrim &>> logs/modmapper.log
|
./target/release/mod-mapper -s mods/skyrim/mod_search_index.json -g skyrim &>> logs/modmapper.log
|
||||||
./target/release/mod-mapper -M mods/mod_cell_counts.json &>> logs/modmapper.log
|
./target/release/mod-mapper -M mods/mod_cell_counts.json &>> logs/modmapper.log
|
||||||
./target/release/mod-mapper -G mods/games.json &>> logs/modmapper.log
|
./target/release/mod-mapper -G mods/games.json &>> logs/modmapper.log
|
||||||
./target/release/mod-mapper -m mods -u "$last_update_time" &>> logs/modmapper.log
|
./target/release/mod-mapper -m mods -u "$last_update_time" &>> logs/modmapper.log
|
||||||
@ -21,8 +21,8 @@ if [ -n "$last_update_time" ]; then
|
|||||||
else
|
else
|
||||||
./target/release/mod-mapper -e cells/edits.json &>> logs/modmapper.log
|
./target/release/mod-mapper -e cells/edits.json &>> logs/modmapper.log
|
||||||
./target/release/mod-mapper -c cells &>> logs/modmapper.log
|
./target/release/mod-mapper -c cells &>> logs/modmapper.log
|
||||||
./target/release/mod-mapper -s mods/skyrimspecialedition_mod_search_index.json -g skyrimspecialedition &>> logs/modmapper.log
|
./target/release/mod-mapper -s mods/skyrimspecialedition/mod_search_index.json -g skyrimspecialedition &>> logs/modmapper.log
|
||||||
./target/release/mod-mapper -s mods/skyrim_mod_search_index.json -g skyrim &>> logs/modmapper.log
|
./target/release/mod-mapper -s mods/skyrim/mod_search_index.json -g skyrim &>> logs/modmapper.log
|
||||||
./target/release/mod-mapper -M mods/mod_cell_counts.json &>> logs/modmapper.log
|
./target/release/mod-mapper -M mods/mod_cell_counts.json &>> logs/modmapper.log
|
||||||
./target/release/mod-mapper -G mods/games.json &>> logs/modmapper.log
|
./target/release/mod-mapper -G mods/games.json &>> logs/modmapper.log
|
||||||
./target/release/mod-mapper -m mods &>> logs/modmapper.log
|
./target/release/mod-mapper -m mods &>> logs/modmapper.log
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
|
use std::collections::HashMap;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
|
use crate::models::game;
|
||||||
use crate::models::game_mod;
|
use crate::models::game_mod;
|
||||||
|
|
||||||
pub async fn dump_mod_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, updated_after: Option<NaiveDateTime>) -> Result<()> {
|
pub async fn dump_mod_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, updated_after: Option<NaiveDateTime>) -> Result<()> {
|
||||||
let mut page = 1;
|
let mut page = 1;
|
||||||
let page_size = 20;
|
let page_size = 20;
|
||||||
let mut last_id = None;
|
let mut last_id = None;
|
||||||
|
let game_id_to_name: HashMap<_, _> = game::get_all(&pool).await?.into_iter().map(|game| (game.id, game.name)).collect();
|
||||||
loop {
|
loop {
|
||||||
let mods =
|
let mods =
|
||||||
game_mod::batched_get_with_cells_and_files(&pool, page_size, last_id, "Skyrim.esm", 1, updated_after).await?;
|
game_mod::batched_get_with_cells_and_files(&pool, page_size, last_id, "Skyrim.esm", 1, updated_after).await?;
|
||||||
@ -18,7 +21,7 @@ pub async fn dump_mod_data(pool: &sqlx::Pool<sqlx::Postgres>, dir: &str, updated
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for mod_with_cells in mods {
|
for mod_with_cells in mods {
|
||||||
let path = Path::new(&dir);
|
let path = Path::new(&dir).join(game_id_to_name.get(&mod_with_cells.game_id).expect("valid mod.game_id"));
|
||||||
std::fs::create_dir_all(&path)?;
|
std::fs::create_dir_all(&path)?;
|
||||||
let path = path.join(format!("{}.json", mod_with_cells.nexus_mod_id));
|
let path = path.join(format!("{}.json", mod_with_cells.nexus_mod_id));
|
||||||
info!(page = page, nexus_mod_id = mod_with_cells.nexus_mod_id, "dumping mod data to {}", path.display());
|
info!(page = page, nexus_mod_id = mod_with_cells.nexus_mod_id, "dumping mod data to {}", path.display());
|
||||||
|
Loading…
Reference in New Issue
Block a user