1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 17:27:48 +08:00

Move StoragePath implementation to an extension method

This commit is contained in:
Dean Herbert 2021-11-19 16:07:55 +09:00
parent c6c6b04f2b
commit 59e763467f
23 changed files with 58 additions and 37 deletions

View File

@ -16,6 +16,7 @@ using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
@ -363,15 +364,15 @@ namespace osu.Game.Tests.Beatmaps.IO
var files = osu.Dependencies.Get<FileStore>(); var files = osu.Dependencies.Get<FileStore>();
long originalLength; long originalLength;
using (var stream = files.Storage.GetStream(firstFile.FileInfo.StoragePath)) using (var stream = files.Storage.GetStream(firstFile.FileInfo.GetStoragePath()))
originalLength = stream.Length; originalLength = stream.Length;
using (var stream = files.Storage.GetStream(firstFile.FileInfo.StoragePath, FileAccess.Write, FileMode.Create)) using (var stream = files.Storage.GetStream(firstFile.FileInfo.GetStoragePath(), FileAccess.Write, FileMode.Create))
stream.WriteByte(0); stream.WriteByte(0);
var importedSecondTime = await LoadOszIntoOsu(osu); var importedSecondTime = await LoadOszIntoOsu(osu);
using (var stream = files.Storage.GetStream(firstFile.FileInfo.StoragePath)) using (var stream = files.Storage.GetStream(firstFile.FileInfo.GetStoragePath()))
Assert.AreEqual(stream.Length, originalLength, "Corruption was not fixed on second import"); Assert.AreEqual(stream.Length, originalLength, "Corruption was not fixed on second import");
// check the newly "imported" beatmap is actually just the restored previous import. since it matches hash. // check the newly "imported" beatmap is actually just the restored previous import. since it matches hash.

View File

@ -14,6 +14,7 @@ using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.IO.Archives; using osu.Game.IO.Archives;
using osu.Game.Models; using osu.Game.Models;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
@ -348,15 +349,15 @@ namespace osu.Game.Tests.Database
var firstFile = imported.Files.First(); var firstFile = imported.Files.First();
long originalLength; long originalLength;
using (var stream = storage.GetStream(firstFile.File.StoragePath)) using (var stream = storage.GetStream(firstFile.File.GetStoragePath()))
originalLength = stream.Length; originalLength = stream.Length;
using (var stream = storage.GetStream(firstFile.File.StoragePath, FileAccess.Write, FileMode.Create)) using (var stream = storage.GetStream(firstFile.File.GetStoragePath(), FileAccess.Write, FileMode.Create))
stream.WriteByte(0); stream.WriteByte(0);
var importedSecondTime = await LoadOszIntoStore(importer, realmFactory.Context); var importedSecondTime = await LoadOszIntoStore(importer, realmFactory.Context);
using (var stream = storage.GetStream(firstFile.File.StoragePath)) using (var stream = storage.GetStream(firstFile.File.GetStoragePath()))
Assert.AreEqual(stream.Length, originalLength, "Corruption was not fixed on second import"); Assert.AreEqual(stream.Length, originalLength, "Corruption was not fixed on second import");
// check the newly "imported" beatmap is actually just the restored previous import. since it matches hash. // check the newly "imported" beatmap is actually just the restored previous import. since it matches hash.

View File

@ -6,6 +6,7 @@ using System.IO;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Game.Extensions;
using osu.Game.Models; using osu.Game.Models;
using osu.Game.Stores; using osu.Game.Stores;
@ -28,7 +29,7 @@ namespace osu.Game.Tests.Database
realm.Write(() => files.Add(testData, realm)); realm.Write(() => files.Add(testData, realm));
Assert.True(files.Storage.Exists("0/05/054edec1d0211f624fed0cbca9d4f9400b0e491c43742af2c5b0abebf0c990d8")); Assert.True(files.Storage.Exists("0/05/054edec1d0211f624fed0cbca9d4f9400b0e491c43742af2c5b0abebf0c990d8"));
Assert.True(files.Storage.Exists(realm.All<RealmFile>().First().StoragePath)); Assert.True(files.Storage.Exists(realm.All<RealmFile>().First().GetStoragePath()));
}); });
} }
@ -74,7 +75,7 @@ namespace osu.Game.Tests.Database
Logger.Log($"Import complete at {timer.ElapsedMilliseconds}"); Logger.Log($"Import complete at {timer.ElapsedMilliseconds}");
string path = file.StoragePath; string path = file.GetStoragePath();
Assert.True(realm.All<RealmFile>().Any()); Assert.True(realm.All<RealmFile>().Any());
Assert.True(files.Storage.Exists(path)); Assert.True(files.Storage.Exists(path));
@ -98,7 +99,7 @@ namespace osu.Game.Tests.Database
var file = realm.Write(() => files.Add(new MemoryStream(new byte[] { 0, 1, 2, 3 }), realm)); var file = realm.Write(() => files.Add(new MemoryStream(new byte[] { 0, 1, 2, 3 }), realm));
string path = file.StoragePath; string path = file.GetStoragePath();
Assert.True(realm.All<RealmFile>().Any()); Assert.True(realm.All<RealmFile>().Any());
Assert.True(files.Storage.Exists(path)); Assert.True(files.Storage.Exists(path));

View File

@ -18,6 +18,7 @@ using osu.Framework.Platform;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Formats;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.IO.Archives; using osu.Game.IO.Archives;
using osu.Game.Rulesets; using osu.Game.Rulesets;
@ -384,7 +385,7 @@ namespace osu.Game.Beatmaps
foreach (var file in files.Where(f => f.Filename.EndsWith(".osu", StringComparison.OrdinalIgnoreCase))) foreach (var file in files.Where(f => f.Filename.EndsWith(".osu", StringComparison.OrdinalIgnoreCase)))
{ {
using (var raw = Files.Store.GetStream(file.FileInfo.StoragePath)) using (var raw = Files.Store.GetStream(file.FileInfo.GetStoragePath()))
using (var ms = new MemoryStream()) // we need a memory stream so we can seek using (var ms = new MemoryStream()) // we need a memory stream so we can seek
using (var sr = new LineBufferedReader(ms)) using (var sr = new LineBufferedReader(ms))
{ {

View File

@ -8,6 +8,7 @@ using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
@ -61,7 +62,7 @@ namespace osu.Game.Beatmaps
/// The path returned is relative to the user file storage. /// The path returned is relative to the user file storage.
/// </summary> /// </summary>
/// <param name="filename">The name of the file to get the storage path of.</param> /// <param name="filename">The name of the file to get the storage path of.</param>
public string GetPathForFile(string filename) => Files.SingleOrDefault(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath; public string GetPathForFile(string filename) => Files.SingleOrDefault(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.FileInfo.GetStoragePath();
public override string ToString() => Metadata?.ToString() ?? base.ToString(); public override string ToString() => Metadata?.ToString() ?? base.ToString();

View File

@ -325,7 +325,7 @@ namespace osu.Game.Database
foreach (TFileModel file in hashableFiles) foreach (TFileModel file in hashableFiles)
{ {
using (Stream s = Files.Store.GetStream(file.FileInfo.StoragePath)) using (Stream s = Files.Store.GetStream(file.FileInfo.GetStoragePath()))
s.CopyTo(hashable); s.CopyTo(hashable);
} }
@ -480,7 +480,7 @@ namespace osu.Game.Database
using (var archive = ZipArchive.Create()) using (var archive = ZipArchive.Create())
{ {
foreach (var file in model.Files) foreach (var file in model.Files)
archive.AddEntry(file.Filename, Files.Storage.GetStream(file.FileInfo.StoragePath)); archive.AddEntry(file.Filename, Files.Storage.GetStream(file.FileInfo.GetStoragePath()));
archive.SaveTo(outputStream); archive.SaveTo(outputStream);
} }

View File

@ -1,8 +1,10 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.IO;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.IO;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Scoring; using osu.Game.Scoring;
@ -14,6 +16,13 @@ namespace osu.Game.Extensions
{ {
public static class ModelExtensions public static class ModelExtensions
{ {
/// <summary>
/// Get the relative path in osu! storage for this file.
/// </summary>
/// <param name="fileInfo">The file info.</param>
/// <returns>A relative file path.</returns>
public static string GetStoragePath(this IFileInfo fileInfo) => Path.Combine(fileInfo.Hash.Remove(1), fileInfo.Hash.Remove(2), fileInfo.Hash);
/// <summary> /// <summary>
/// Returns a user-facing string representing the <paramref name="model"/>. /// Returns a user-facing string representing the <paramref name="model"/>.
/// </summary> /// </summary>

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.IO;
using osu.Game.Database; using osu.Game.Database;
namespace osu.Game.IO namespace osu.Game.IO
@ -12,8 +11,6 @@ namespace osu.Game.IO
public string Hash { get; set; } public string Hash { get; set; }
public string StoragePath => Path.Combine(Hash.Remove(1), Hash.Remove(2), Hash);
public int ReferenceCount { get; set; } public int ReferenceCount { get; set; }
} }
} }

View File

@ -12,6 +12,7 @@ using osu.Framework.IO.Stores;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions;
namespace osu.Game.IO namespace osu.Game.IO
{ {
@ -47,7 +48,7 @@ namespace osu.Game.IO
var info = existing ?? new FileInfo { Hash = hash }; var info = existing ?? new FileInfo { Hash = hash };
string path = info.StoragePath; string path = info.GetStoragePath();
// we may be re-adding a file to fix missing store entries. // we may be re-adding a file to fix missing store entries.
bool requiresCopy = !Storage.Exists(path); bool requiresCopy = !Storage.Exists(path);
@ -120,7 +121,7 @@ namespace osu.Game.IO
{ {
try try
{ {
Storage.Delete(f.StoragePath); Storage.Delete(f.GetStoragePath());
context.FileInfo.Remove(f); context.FileInfo.Remove(f);
} }
catch (Exception e) catch (Exception e)

View File

@ -52,7 +52,7 @@ namespace osu.Game.Models
/// The path returned is relative to the user file storage. /// The path returned is relative to the user file storage.
/// </summary> /// </summary>
/// <param name="filename">The name of the file to get the storage path of.</param> /// <param name="filename">The name of the file to get the storage path of.</param>
public string? GetPathForFile(string filename) => Files.SingleOrDefault(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.File.StoragePath; public string? GetPathForFile(string filename) => Files.SingleOrDefault(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.File.GetStoragePath();
public bool Equals(RealmBeatmapSet? other) public bool Equals(RealmBeatmapSet? other)
{ {

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.IO;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.IO; using osu.Game.IO;
using Realms; using Realms;
@ -16,7 +15,5 @@ namespace osu.Game.Models
{ {
[PrimaryKey] [PrimaryKey]
public string Hash { get; set; } = string.Empty; public string Hash { get; set; } = string.Empty;
public string StoragePath => Path.Combine(Hash.Remove(1), Hash.Remove(2), Hash);
} }
} }

View File

@ -6,6 +6,7 @@ using System.IO;
using System.Linq; using System.Linq;
using ManagedBass; using ManagedBass;
using osu.Framework.Audio.Callbacks; using osu.Framework.Audio.Callbacks;
using osu.Game.Extensions;
using osu.Game.Rulesets.Edit.Checks.Components; using osu.Game.Rulesets.Edit.Checks.Components;
namespace osu.Game.Rulesets.Edit.Checks namespace osu.Game.Rulesets.Edit.Checks
@ -31,7 +32,7 @@ namespace osu.Game.Rulesets.Edit.Checks
foreach (var file in beatmapSet.Files) foreach (var file in beatmapSet.Files)
{ {
using (Stream data = context.WorkingBeatmap.GetStream(file.FileInfo.StoragePath)) using (Stream data = context.WorkingBeatmap.GetStream(file.FileInfo.GetStoragePath()))
{ {
if (data == null) if (data == null)
continue; continue;

View File

@ -3,6 +3,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using osu.Game.Extensions;
using osu.Game.Rulesets.Edit.Checks.Components; using osu.Game.Rulesets.Edit.Checks.Components;
namespace osu.Game.Rulesets.Edit.Checks namespace osu.Game.Rulesets.Edit.Checks
@ -22,7 +23,7 @@ namespace osu.Game.Rulesets.Edit.Checks
foreach (var file in beatmapSet.Files) foreach (var file in beatmapSet.Files)
{ {
using (Stream data = context.WorkingBeatmap.GetStream(file.FileInfo.StoragePath)) using (Stream data = context.WorkingBeatmap.GetStream(file.FileInfo.GetStoragePath()))
{ {
if (data?.Length == 0) if (data?.Length == 0)
yield return new IssueTemplateZeroBytes(this).Create(file.Filename); yield return new IssueTemplateZeroBytes(this).Create(file.Filename);

View File

@ -5,6 +5,7 @@ using System;
using System.Linq; using System.Linq;
using osu.Framework.IO.Stores; using osu.Framework.IO.Stores;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Extensions;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Scoring.Legacy; using osu.Game.Scoring.Legacy;
@ -16,7 +17,7 @@ namespace osu.Game.Scoring
{ {
ScoreInfo = score; ScoreInfo = score;
string replayFilename = score.Files.FirstOrDefault(f => f.Filename.EndsWith(".osr", StringComparison.InvariantCultureIgnoreCase))?.FileInfo.StoragePath; string replayFilename = score.Files.FirstOrDefault(f => f.Filename.EndsWith(".osr", StringComparison.InvariantCultureIgnoreCase))?.FileInfo.GetStoragePath();
if (replayFilename == null) if (replayFilename == null)
return; return;

View File

@ -13,6 +13,7 @@ using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.IO.Archives; using osu.Game.IO.Archives;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Scoring.Legacy; using osu.Game.Scoring.Legacy;
@ -77,7 +78,7 @@ namespace osu.Game.Scoring
if (file == null) if (file == null)
return; return;
using (var inputStream = Files.Storage.GetStream(file.FileInfo.StoragePath)) using (var inputStream = Files.Storage.GetStream(file.FileInfo.GetStoragePath()))
inputStream.CopyTo(outputStream); inputStream.CopyTo(outputStream);
} }

View File

@ -7,6 +7,7 @@ using System.Linq;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.IO.Stores; using osu.Framework.IO.Stores;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -35,7 +36,7 @@ namespace osu.Game.Skinning
} }
private string getPathForFile(string filename) => private string getPathForFile(string filename) =>
source.Files.Find(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath; source.Files.Find(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.FileInfo.GetStoragePath();
public override IEnumerable<string> GetAvailableResources() => source.Files.Select(f => f.Filename); public override IEnumerable<string> GetAvailableResources() => source.Files.Select(f => f.Filename);
} }

View File

@ -15,6 +15,7 @@ using osu.Framework.Graphics.OpenGL.Textures;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Extensions;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.HUD;
@ -63,7 +64,7 @@ namespace osu.Game.Skinning
if (fileInfo == null) if (fileInfo == null)
continue; continue;
byte[] bytes = resources?.Files.Get(fileInfo.FileInfo.StoragePath); byte[] bytes = resources?.Files.Get(fileInfo.FileInfo.GetStoragePath());
if (bytes == null) if (bytes == null)
continue; continue;
@ -93,7 +94,7 @@ namespace osu.Game.Skinning
private Stream getConfigurationStream() private Stream getConfigurationStream()
{ {
string path = SkinInfo.Files.SingleOrDefault(f => f.Filename.Equals(@"skin.ini", StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath; string path = SkinInfo.Files.SingleOrDefault(f => f.Filename.Equals(@"skin.ini", StringComparison.OrdinalIgnoreCase))?.FileInfo.GetStoragePath();
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
return null; return null;

View File

@ -215,7 +215,7 @@ namespace osu.Game.Skinning
{ {
using (var sw = new StreamWriter(stream, Encoding.UTF8, 1024, true)) using (var sw = new StreamWriter(stream, Encoding.UTF8, 1024, true))
{ {
using (var existingStream = Files.Storage.GetStream(existingFile.FileInfo.StoragePath)) using (var existingStream = Files.Storage.GetStream(existingFile.FileInfo.GetStoragePath()))
using (var sr = new StreamReader(existingStream)) using (var sr = new StreamReader(existingStream))
{ {
string line; string line;

View File

@ -18,6 +18,7 @@ using osu.Framework.Testing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Formats;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.IO.Archives; using osu.Game.IO.Archives;
using osu.Game.Models; using osu.Game.Models;
@ -197,7 +198,7 @@ namespace osu.Game.Stores
foreach (var file in files.Where(f => f.Filename.EndsWith(".osu", StringComparison.OrdinalIgnoreCase))) foreach (var file in files.Where(f => f.Filename.EndsWith(".osu", StringComparison.OrdinalIgnoreCase)))
{ {
using (var memoryStream = new MemoryStream(Files.Store.Get(file.File.StoragePath))) // we need a memory stream so we can seek using (var memoryStream = new MemoryStream(Files.Store.Get(file.File.GetStoragePath()))) // we need a memory stream so we can seek
{ {
IBeatmap decoded; IBeatmap decoded;
using (var lineReader = new LineBufferedReader(memoryStream, true)) using (var lineReader = new LineBufferedReader(memoryStream, true))

View File

@ -15,6 +15,7 @@ using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.IO.Archives; using osu.Game.IO.Archives;
using osu.Game.Models; using osu.Game.Models;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
@ -305,7 +306,7 @@ namespace osu.Game.Stores
foreach (RealmNamedFileUsage file in item.Files.Where(f => HashableFileTypes.Any(ext => f.Filename.EndsWith(ext, StringComparison.OrdinalIgnoreCase))).OrderBy(f => f.Filename)) foreach (RealmNamedFileUsage file in item.Files.Where(f => HashableFileTypes.Any(ext => f.Filename.EndsWith(ext, StringComparison.OrdinalIgnoreCase))).OrderBy(f => f.Filename))
{ {
using (Stream s = Files.Store.GetStream(file.File.StoragePath)) using (Stream s = Files.Store.GetStream(file.File.GetStoragePath()))
s.CopyTo(hashable); s.CopyTo(hashable);
} }

View File

@ -10,6 +10,7 @@ using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.Models; using osu.Game.Models;
using Realms; using Realms;
@ -64,7 +65,7 @@ namespace osu.Game.Stores
{ {
data.Seek(0, SeekOrigin.Begin); data.Seek(0, SeekOrigin.Begin);
using (var output = Storage.GetStream(file.StoragePath, FileAccess.Write)) using (var output = Storage.GetStream(file.GetStoragePath(), FileAccess.Write))
data.CopyTo(output); data.CopyTo(output);
data.Seek(0, SeekOrigin.Begin); data.Seek(0, SeekOrigin.Begin);
@ -72,7 +73,7 @@ namespace osu.Game.Stores
private bool checkFileExistsAndMatchesHash(RealmFile file) private bool checkFileExistsAndMatchesHash(RealmFile file)
{ {
string path = file.StoragePath; string path = file.GetStoragePath();
// we may be re-adding a file to fix missing store entries. // we may be re-adding a file to fix missing store entries.
if (!Storage.Exists(path)) if (!Storage.Exists(path))
@ -100,7 +101,7 @@ namespace osu.Game.Stores
try try
{ {
Storage.Delete(file.StoragePath); Storage.Delete(file.GetStoragePath());
realm.Remove(file); realm.Remove(file);
} }
catch (Exception e) catch (Exception e)

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -9,6 +10,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics.Video; using osu.Framework.Graphics.Video;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Extensions;
namespace osu.Game.Storyboards.Drawables namespace osu.Game.Storyboards.Drawables
{ {
@ -29,7 +31,7 @@ namespace osu.Game.Storyboards.Drawables
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(IBindable<WorkingBeatmap> beatmap, TextureStore textureStore) private void load(IBindable<WorkingBeatmap> beatmap, TextureStore textureStore)
{ {
string path = beatmap.Value.BeatmapSetInfo?.Files.Find(f => f.Filename.Equals(Video.Path, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath; string path = beatmap.Value.BeatmapSetInfo?.Files.FirstOrDefault(f => f.Filename.Equals(Video.Path, StringComparison.OrdinalIgnoreCase))?.File.GetStoragePath();
if (path == null) if (path == null)
return; return;

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Extensions;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Storyboards.Drawables; using osu.Game.Storyboards.Drawables;
@ -95,7 +96,7 @@ namespace osu.Game.Storyboards
public Drawable CreateSpriteFromResourcePath(string path, TextureStore textureStore) public Drawable CreateSpriteFromResourcePath(string path, TextureStore textureStore)
{ {
Drawable drawable = null; Drawable drawable = null;
string storyboardPath = BeatmapInfo.BeatmapSet?.Files.Find(f => f.Filename.Equals(path, StringComparison.OrdinalIgnoreCase))?.FileInfo.StoragePath; string storyboardPath = BeatmapInfo.BeatmapSet?.Files.Find(f => f.Filename.Equals(path, StringComparison.OrdinalIgnoreCase))?.FileInfo.GetStoragePath();
if (!string.IsNullOrEmpty(storyboardPath)) if (!string.IsNullOrEmpty(storyboardPath))
drawable = new Sprite { Texture = textureStore.Get(storyboardPath) }; drawable = new Sprite { Texture = textureStore.Get(storyboardPath) };