Merge pull request #5007 from jellyfin/create

This commit is contained in:
Joshua M. Boniface 2021-01-16 13:28:48 -05:00 committed by GitHub
commit 03242a6afd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 8 deletions

View File

@ -177,7 +177,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
lock (_lastExecutionResultSyncLock)
{
using FileStream createStream = File.OpenWrite(path);
using FileStream createStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
JsonSerializer.SerializeAsync(createStream, value, _jsonOptions);
}
}
@ -577,9 +577,8 @@ namespace Emby.Server.Implementations.ScheduledTasks
var path = GetConfigurationFilePath();
Directory.CreateDirectory(Path.GetDirectoryName(path));
var json = JsonSerializer.Serialize(triggers, _jsonOptions);
File.WriteAllText(path, json, Encoding.UTF8);
using FileStream createStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
JsonSerializer.SerializeAsync(createStream, triggers, _jsonOptions);
}
/// <summary>

View File

@ -272,6 +272,10 @@ namespace MediaBrowser.Providers.Plugins.Omdb
return path;
}
}
else
{
Directory.CreateDirectory(Path.GetDirectoryName(path));
}
var url = GetOmdbUrl(
string.Format(
@ -280,8 +284,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
imdbParam));
var rootObject = await GetDeserializedOmdbResponse<RootObject>(_httpClientFactory.CreateClient(NamedClient.Default), url, cancellationToken).ConfigureAwait(false);
Directory.CreateDirectory(Path.GetDirectoryName(path));
await using FileStream jsonFileStream = File.OpenWrite(path);
await using FileStream jsonFileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
await JsonSerializer.SerializeAsync(jsonFileStream, rootObject, _jsonOptions, cancellationToken).ConfigureAwait(false);
return path;
@ -308,6 +311,10 @@ namespace MediaBrowser.Providers.Plugins.Omdb
return path;
}
}
else
{
Directory.CreateDirectory(Path.GetDirectoryName(path));
}
var url = GetOmdbUrl(
string.Format(
@ -317,8 +324,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
seasonId));
var rootObject = await GetDeserializedOmdbResponse<SeasonRootObject>(_httpClientFactory.CreateClient(NamedClient.Default), url, cancellationToken).ConfigureAwait(false);
Directory.CreateDirectory(Path.GetDirectoryName(path));
await using FileStream jsonFileStream = File.OpenWrite(path);
await using FileStream jsonFileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
await JsonSerializer.SerializeAsync(jsonFileStream, rootObject, _jsonOptions, cancellationToken).ConfigureAwait(false);
return path;