Skip to content

Commit

Permalink
Merge pull request #350 from NuanRMxi/main
Browse files Browse the repository at this point in the history
修复:删除在data.json中不存在的谱面时会导致游戏卡死
  • Loading branch information
ParaN3xus authored Aug 3, 2024
2 parents d20efc5 + d18dc40 commit 2c12a6d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion phira/src/charts_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ impl ChartsView {
format!("download/{}", item.chart.as_ref().unwrap().info.id.unwrap())
};
std::fs::remove_dir_all(format!("{}/{path}", dir::charts()?))?;
data.charts.remove(data.find_chart_by_path(path.as_str()).unwrap());

if let Some(chart) = data.find_chart_by_path(path.as_str()) {
data.charts.remove(chart);
}

save_data()?;
NEED_UPDATE.store(true, Ordering::SeqCst);
} else {
Expand Down

0 comments on commit 2c12a6d

Please sign in to comment.