Fix file prefix not being read when calling storage.Exists

This commit is contained in:
Dean Herbert
2017-10-17 17:08:19 +09:00
parent e02640637a
commit 64dfce258f

View File

@ -18,21 +18,21 @@ namespace osu.Game.IO
/// </summary> /// </summary>
public class FileStore : DatabaseBackedStore public class FileStore : DatabaseBackedStore
{ {
private const string prefix = "files"; public readonly IResourceStore<byte[]> Store;
public readonly ResourceStore<byte[]> Store; public Storage Storage => base.Storage;
public FileStore(Func<OsuDbContext> getContext, Storage storage) : base(getContext, storage) public FileStore(Func<OsuDbContext> getContext, Storage storage) : base(getContext, storage.GetStorageForDirectory(@"files"))
{ {
Store = new NamespacedResourceStore<byte[]>(new StorageBackedResourceStore(storage), prefix); Store = new StorageBackedResourceStore(Storage);
} }
protected override void Prepare(bool reset = false) protected override void Prepare(bool reset = false)
{ {
if (reset) if (reset)
{ {
if (Storage.ExistsDirectory(prefix)) if (Storage.ExistsDirectory(string.Empty))
Storage.DeleteDirectory(prefix); Storage.DeleteDirectory(string.Empty);
GetContext().Database.ExecuteSqlCommand("DELETE FROM FileInfo"); GetContext().Database.ExecuteSqlCommand("DELETE FROM FileInfo");
} }
@ -54,7 +54,7 @@ namespace osu.Game.IO
var info = existing ?? new FileInfo { Hash = hash }; var info = existing ?? new FileInfo { Hash = hash };
string path = Path.Combine(prefix, info.StoragePath); string path = info.StoragePath;
// 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))
@ -109,7 +109,7 @@ namespace osu.Game.IO
{ {
try try
{ {
Storage.Delete(Path.Combine(prefix, f.StoragePath)); Storage.Delete(f.StoragePath);
context.FileInfo.Remove(f); context.FileInfo.Remove(f);
} }
catch (Exception e) catch (Exception e)