mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 06:52:56 +08:00
Remove the previous audio file before adding a new one
This commit is contained in:
parent
4d714866cd
commit
65e6dd2ac3
@ -144,14 +144,29 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
var info = new FileInfo(filePath.NewValue);
|
||||
|
||||
if (!info.Exists)
|
||||
{
|
||||
audioTrackTextBox.Current.Value = filePath.OldValue;
|
||||
return;
|
||||
}
|
||||
|
||||
var beatmapFiles = Beatmap.Value.BeatmapSetInfo.Files;
|
||||
|
||||
// remove the old file
|
||||
var oldFile = beatmapFiles.FirstOrDefault(f => f.Filename == filePath.OldValue);
|
||||
|
||||
if (oldFile != null)
|
||||
{
|
||||
beatmapFiles.Remove(oldFile);
|
||||
files.Dereference(oldFile.FileInfo);
|
||||
}
|
||||
|
||||
// add the new file
|
||||
IO.FileInfo osuFileInfo;
|
||||
|
||||
using (var stream = info.OpenRead())
|
||||
osuFileInfo = files.Add(stream);
|
||||
|
||||
Beatmap.Value.BeatmapSetInfo.Files.Add(new BeatmapSetFileInfo
|
||||
beatmapFiles.Add(new BeatmapSetFileInfo
|
||||
{
|
||||
FileInfo = osuFileInfo,
|
||||
Filename = info.Name
|
||||
|
Loading…
Reference in New Issue
Block a user