mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
better disposal around using
This commit is contained in:
parent
88ff3e4a9b
commit
196f3eb574
@ -468,17 +468,17 @@ namespace MediaBrowser.Server.Implementations.Providers
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// If the file already exists but is hidden, the below save will throw an UnauthorizedAccessException
|
using (dataToSave)
|
||||||
var existingFileInfo = new FileInfo(path);
|
|
||||||
|
|
||||||
if (existingFileInfo.Exists && existingFileInfo.Attributes.HasFlag(FileAttributes.Hidden))
|
|
||||||
{
|
{
|
||||||
existingFileInfo.Delete();
|
// If the file already exists but is hidden, the below save will throw an UnauthorizedAccessException
|
||||||
}
|
var existingFileInfo = new FileInfo(path);
|
||||||
|
|
||||||
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous))
|
if (existingFileInfo.Exists && existingFileInfo.Attributes.HasFlag(FileAttributes.Hidden))
|
||||||
{
|
{
|
||||||
using (dataToSave)
|
existingFileInfo.Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous))
|
||||||
{
|
{
|
||||||
await dataToSave.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, cancellationToken).ConfigureAwait(false);
|
await dataToSave.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user