Skip to content

Commit

Permalink
make sure CHD parents aren't modified if they still have children
Browse files Browse the repository at this point in the history
  • Loading branch information
alucryd committed Apr 5, 2024
1 parent e0d6019 commit f8f324b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/convert_roms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,13 @@ async fn to_archive(
let rom = roms.first().unwrap();
let game = games_by_id.get(&rom.game_id).unwrap();
let romfile = romfiles_by_id.get(&rom.romfile_id.unwrap()).unwrap();
if !find_romfiles_by_parent_id(&mut transaction, romfile.id)
.await
.is_empty()
{
progress_bar.println("CHD has children, skipping");
continue;
}
let chd_romfile = match romfile.parent_id {
Some(parent_id) => {
let parent_chd_romfile = find_romfile_by_id(&mut transaction, parent_id).await;
Expand Down Expand Up @@ -572,6 +579,13 @@ async fn to_archive(
let romfile = romfiles_by_id
.get(&bin_roms.first().unwrap().romfile_id.unwrap())
.unwrap();
if !find_romfiles_by_parent_id(&mut transaction, romfile.id)
.await
.is_empty()
{
progress_bar.println("CHD has children, skipping");
continue;
}
let chd_romfile = match romfile.parent_id {
Some(parent_id) => {
let parent_chd_romfile = find_romfile_by_id(&mut transaction, parent_id).await;
Expand Down Expand Up @@ -2221,6 +2235,13 @@ async fn to_cso(
let mut transaction = begin_transaction(connection).await;
for rom in roms {
let romfile = romfiles_by_id.get(&rom.romfile_id.unwrap()).unwrap();
if !find_romfiles_by_parent_id(&mut transaction, romfile.id)
.await
.is_empty()
{
progress_bar.println("CHD has children, skipping");
continue;
}
let chd_romfile = match romfile.parent_id {
Some(parent_id) => {
let parent_chd_romfile = find_romfile_by_id(&mut transaction, parent_id).await;
Expand Down Expand Up @@ -3037,6 +3058,13 @@ async fn to_zso(
let mut transaction = begin_transaction(connection).await;
for rom in roms {
let romfile = romfiles_by_id.get(&rom.romfile_id.unwrap()).unwrap();
if !find_romfiles_by_parent_id(&mut transaction, romfile.id)
.await
.is_empty()
{
progress_bar.println("CHD has children, skipping");
continue;
}
let chd_romfile = match romfile.parent_id {
Some(parent_id) => {
let parent_chd_romfile = find_romfile_by_id(&mut transaction, parent_id).await;
Expand Down Expand Up @@ -3404,6 +3432,13 @@ async fn to_original(
let romfile = romfiles_by_id
.get(&roms.first().unwrap().romfile_id.unwrap())
.unwrap();
if !find_romfiles_by_parent_id(&mut transaction, romfile.id)
.await
.is_empty()
{
progress_bar.println("CHD has children, skipping");
continue;
}
let chd_romfile = match romfile.parent_id {
Some(parent_id) => {
let parent_chd_romfile = find_romfile_by_id(&mut transaction, parent_id).await;
Expand Down Expand Up @@ -3460,6 +3495,13 @@ async fn to_original(
}

let romfile = romfiles.first().unwrap();
if !find_romfiles_by_parent_id(&mut transaction, romfile.id)
.await
.is_empty()
{
progress_bar.println("CHD has children, skipping");
continue;
}
let cue_romfile = romfiles_by_id
.get(&cue_roms.first().unwrap().romfile_id.unwrap())
.unwrap()
Expand Down

0 comments on commit f8f324b

Please sign in to comment.