mirror of
https://github.com/osukey/osukey.git
synced 2025-06-23 12:18:03 +09:00
Merge remote-tracking branch 'upstream/master' into merge-projects
This commit is contained in:
commit
4b0eee2bcc
@ -429,6 +429,15 @@ namespace osu.Game.Beatmaps
|
|||||||
if (beatmapSet != null)
|
if (beatmapSet != null)
|
||||||
{
|
{
|
||||||
Undelete(beatmapSet);
|
Undelete(beatmapSet);
|
||||||
|
|
||||||
|
// ensure all files are present and accessible
|
||||||
|
foreach (var f in beatmapSet.Files)
|
||||||
|
{
|
||||||
|
if (!storage.Exists(f.FileInfo.StoragePath))
|
||||||
|
using (Stream s = reader.GetStream(f.Filename))
|
||||||
|
files.Add(s, false);
|
||||||
|
}
|
||||||
|
|
||||||
return beatmapSet;
|
return beatmapSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,33 +78,33 @@ namespace osu.Game.IO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileInfo Add(Stream data)
|
public FileInfo Add(Stream data, bool reference = true)
|
||||||
{
|
{
|
||||||
string hash = data.ComputeSHA2Hash();
|
string hash = data.ComputeSHA2Hash();
|
||||||
|
|
||||||
var existing = Connection.Table<FileInfo>().Where(f => f.Hash == hash).FirstOrDefault();
|
var existing = Connection.Table<FileInfo>().Where(f => f.Hash == hash).FirstOrDefault();
|
||||||
|
|
||||||
var info = existing ?? new FileInfo { Hash = hash };
|
var info = existing ?? new FileInfo { Hash = hash };
|
||||||
if (existing != null)
|
|
||||||
{
|
|
||||||
info = existing;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string path = Path.Combine(prefix, info.StoragePath);
|
string path = Path.Combine(prefix, info.StoragePath);
|
||||||
|
|
||||||
|
// we may be re-adding a file to fix missing store entries.
|
||||||
|
if (!Storage.Exists(path))
|
||||||
|
{
|
||||||
data.Seek(0, SeekOrigin.Begin);
|
data.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
if (!Storage.Exists(path))
|
|
||||||
using (var output = Storage.GetStream(path, FileAccess.Write))
|
using (var output = Storage.GetStream(path, FileAccess.Write))
|
||||||
data.CopyTo(output);
|
data.CopyTo(output);
|
||||||
|
|
||||||
data.Seek(0, SeekOrigin.Begin);
|
data.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
Connection.Insert(info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (existing == null)
|
||||||
|
Connection.Insert(info);
|
||||||
|
|
||||||
|
if (reference || existing == null)
|
||||||
Reference(info);
|
Reference(info);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user