mirror of
https://github.com/osukey/osukey.git
synced 2025-06-28 14:48:04 +09:00
Fix NRT and add more safety
This commit is contained in:
parent
de21864bd1
commit
e16105d059
@ -38,10 +38,11 @@ namespace osu.Android
|
|||||||
if (cursor == null)
|
if (cursor == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
cursor.MoveToFirst();
|
if (!cursor.MoveToFirst())
|
||||||
|
return null;
|
||||||
|
|
||||||
int filenameColumn = cursor.GetColumnIndex(IOpenableColumns.DisplayName);
|
int filenameColumn = cursor.GetColumnIndex(IOpenableColumns.DisplayName);
|
||||||
string filename = cursor.GetString(filenameColumn);
|
string filename = cursor.GetString(filenameColumn) ?? uri.Path ?? string.Empty;
|
||||||
|
|
||||||
// SharpCompress requires archive streams to be seekable, which the stream opened by
|
// SharpCompress requires archive streams to be seekable, which the stream opened by
|
||||||
// OpenInputStream() seems to not necessarily be.
|
// OpenInputStream() seems to not necessarily be.
|
||||||
@ -49,7 +50,12 @@ namespace osu.Android
|
|||||||
var copy = new MemoryStream();
|
var copy = new MemoryStream();
|
||||||
|
|
||||||
using (var stream = contentResolver.OpenInputStream(uri))
|
using (var stream = contentResolver.OpenInputStream(uri))
|
||||||
|
{
|
||||||
|
if (stream == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
await stream.CopyToAsync(copy).ConfigureAwait(false);
|
await stream.CopyToAsync(copy).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
return new AndroidImportTask(copy, filename, contentResolver, uri);
|
return new AndroidImportTask(copy, filename, contentResolver, uri);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user