Merge pull request #5007 from jellyfin/create

pull/5033/head
Joshua M. Boniface 4 years ago committed by GitHub
commit 03242a6afd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

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

Loading…
Cancel
Save