mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Merge pull request #18777 from peppy/output-directory-on-import-failure
Silence exception and provide more log output when import fails due to empty `.osu` files
This commit is contained in:
@ -276,6 +276,42 @@ namespace osu.Game.Tests.Database
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestImportDirectoryWithEmptyOsuFiles()
|
||||
{
|
||||
RunTestWithRealmAsync(async (realm, storage) =>
|
||||
{
|
||||
using var importer = new BeatmapImporter(storage, realm);
|
||||
using var store = new RealmRulesetStore(realm, storage);
|
||||
|
||||
string? temp = TestResources.GetTestBeatmapForImport();
|
||||
|
||||
string extractedFolder = $"{temp}_extracted";
|
||||
Directory.CreateDirectory(extractedFolder);
|
||||
|
||||
try
|
||||
{
|
||||
using (var zip = ZipArchive.Open(temp))
|
||||
zip.WriteToDirectory(extractedFolder);
|
||||
|
||||
foreach (var file in new DirectoryInfo(extractedFolder).GetFiles("*.osu"))
|
||||
{
|
||||
using (file.Open(FileMode.Create))
|
||||
{
|
||||
// empty file.
|
||||
}
|
||||
}
|
||||
|
||||
var imported = await importer.Import(new ImportTask(extractedFolder));
|
||||
Assert.IsNull(imported);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Directory.Delete(extractedFolder, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestImportThenImportWithReZip()
|
||||
{
|
||||
|
Reference in New Issue
Block a user