mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 14:08:44 -04:00
Unwrapped all /(Write|Read)All(Text|Bytes)/ functions.
This commit is contained in:
parent
581a7fe078
commit
b9a111432a
17 changed files with 36 additions and 29 deletions
|
@ -210,7 +210,8 @@ namespace Emby.Server.Implementations.AppBase
|
||||||
{
|
{
|
||||||
var file = Path.Combine(path, Guid.NewGuid().ToString());
|
var file = Path.Combine(path, Guid.NewGuid().ToString());
|
||||||
|
|
||||||
FileSystem.WriteAllText(file, string.Empty);
|
string text = string.Empty;
|
||||||
|
File.WriteAllText(file, text);
|
||||||
FileSystem.DeleteFile(file);
|
FileSystem.DeleteFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.AppBase
|
||||||
// Use try/catch to avoid the extra file system lookup using File.Exists
|
// Use try/catch to avoid the extra file system lookup using File.Exists
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
buffer = fileSystem.ReadAllBytes(path);
|
buffer = File.ReadAllBytes(path);
|
||||||
|
|
||||||
configuration = xmlSerializer.DeserializeFromBytes(type, buffer);
|
configuration = xmlSerializer.DeserializeFromBytes(type, buffer);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.AppBase
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||||
|
|
||||||
// Save it after load in case we got new items
|
// Save it after load in case we got new items
|
||||||
fileSystem.WriteAllBytes(path, newBytes);
|
File.WriteAllBytes(path, newBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return configuration;
|
return configuration;
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace Emby.Server.Implementations.Devices
|
||||||
|
|
||||||
lock (_syncLock)
|
lock (_syncLock)
|
||||||
{
|
{
|
||||||
_fileSystem.WriteAllText(path, id, Encoding.UTF8);
|
File.WriteAllText(path, id, Encoding.UTF8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Emby.Server.Implementations.IO
|
||||||
|
|
||||||
if (string.Equals(Path.GetExtension(shortcutPath), ".mblink", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(Path.GetExtension(shortcutPath), ".mblink", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var path = _fileSystem.ReadAllText(shortcutPath);
|
var path = File.ReadAllText(shortcutPath);
|
||||||
|
|
||||||
return _fileSystem.NormalizePath(path);
|
return _fileSystem.NormalizePath(path);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ namespace Emby.Server.Implementations.IO
|
||||||
throw new ArgumentNullException(nameof(targetPath));
|
throw new ArgumentNullException(nameof(targetPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
_fileSystem.WriteAllText(shortcutPath, targetPath);
|
File.WriteAllText(shortcutPath, targetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2889,7 +2889,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
var path = Path.Combine(virtualFolderPath, collectionType + ".collection");
|
var path = Path.Combine(virtualFolderPath, collectionType + ".collection");
|
||||||
|
|
||||||
_fileSystem.WriteAllBytes(path, Array.Empty<byte>());
|
File.WriteAllBytes(path, Array.Empty<byte>());
|
||||||
}
|
}
|
||||||
|
|
||||||
CollectionFolder.SaveLibraryOptions(virtualFolderPath, options);
|
CollectionFolder.SaveLibraryOptions(virtualFolderPath, options);
|
||||||
|
|
|
@ -904,7 +904,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
// Tuesday, 22 August 2006 06:30 AM
|
// Tuesday, 22 August 2006 06:30 AM
|
||||||
text.AppendLine("The pin code will expire at " + localExpirationTime.ToString("f1", CultureInfo.CurrentCulture));
|
text.AppendLine("The pin code will expire at " + localExpirationTime.ToString("f1", CultureInfo.CurrentCulture));
|
||||||
|
|
||||||
_fileSystem.WriteAllText(path, text.ToString(), Encoding.UTF8);
|
File.WriteAllText(path, text.ToString(), Encoding.UTF8);
|
||||||
|
|
||||||
var result = new PasswordPinCreationResult
|
var result = new PasswordPinCreationResult
|
||||||
{
|
{
|
||||||
|
|
|
@ -340,7 +340,8 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
playlist.PlaylistEntries.Add(entry);
|
playlist.PlaylistEntries.Add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
_fileSystem.WriteAllText(playlistPath, new WplContent().ToText(playlist));
|
string text = new WplContent().ToText(playlist);
|
||||||
|
File.WriteAllText(playlistPath, text);
|
||||||
}
|
}
|
||||||
if (string.Equals(".zpl", extension, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(".zpl", extension, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -373,7 +374,8 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
playlist.PlaylistEntries.Add(entry);
|
playlist.PlaylistEntries.Add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
_fileSystem.WriteAllText(playlistPath, new ZplContent().ToText(playlist));
|
string text = new ZplContent().ToText(playlist);
|
||||||
|
File.WriteAllText(playlistPath, text);
|
||||||
}
|
}
|
||||||
if (string.Equals(".m3u", extension, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(".m3u", extension, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -401,7 +403,8 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
playlist.PlaylistEntries.Add(entry);
|
playlist.PlaylistEntries.Add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
_fileSystem.WriteAllText(playlistPath, new M3uContent().ToText(playlist));
|
string text = new M3uContent().ToText(playlist);
|
||||||
|
File.WriteAllText(playlistPath, text);
|
||||||
}
|
}
|
||||||
if (string.Equals(".m3u8", extension, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(".m3u8", extension, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -429,7 +432,8 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
playlist.PlaylistEntries.Add(entry);
|
playlist.PlaylistEntries.Add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
_fileSystem.WriteAllText(playlistPath, new M3u8Content().ToText(playlist));
|
string text = new M3u8Content().ToText(playlist);
|
||||||
|
File.WriteAllText(playlistPath, text);
|
||||||
}
|
}
|
||||||
if (string.Equals(".pls", extension, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(".pls", extension, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -449,7 +453,8 @@ namespace Emby.Server.Implementations.Playlists
|
||||||
playlist.PlaylistEntries.Add(entry);
|
playlist.PlaylistEntries.Add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
_fileSystem.WriteAllText(playlistPath, new PlsContent().ToText(playlist));
|
string text = new PlsContent().ToText(playlist);
|
||||||
|
File.WriteAllText(playlistPath, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Emby.Server.Implementations
|
||||||
|
|
||||||
public string ReadAllText(string basePath, string virtualPath)
|
public string ReadAllText(string basePath, string virtualPath)
|
||||||
{
|
{
|
||||||
return _fileSystem.ReadAllText(GetResourcePath(basePath, virtualPath));
|
return File.ReadAllText(GetResourcePath(basePath, virtualPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetResourcePath(string basePath, string virtualPath)
|
private string GetResourcePath(string basePath, string virtualPath)
|
||||||
|
|
|
@ -105,7 +105,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
previouslyFailedImages = _fileSystem.ReadAllText(failHistoryPath)
|
previouslyFailedImages = File.ReadAllText(failHistoryPath)
|
||||||
.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
|
.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,8 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
|
|
||||||
Directory.CreateDirectory(parentPath);
|
Directory.CreateDirectory(parentPath);
|
||||||
|
|
||||||
_fileSystem.WriteAllText(failHistoryPath, string.Join("|", previouslyFailedImages.ToArray()));
|
string text = string.Join("|", previouslyFailedImages.ToArray());
|
||||||
|
File.WriteAllText(failHistoryPath, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
numComplete++;
|
numComplete++;
|
||||||
|
|
|
@ -575,7 +575,7 @@ namespace Emby.Server.Implementations.Updates
|
||||||
//If it is an archive - write out a version file so we know what it is
|
//If it is an archive - write out a version file so we know what it is
|
||||||
if (isArchive)
|
if (isArchive)
|
||||||
{
|
{
|
||||||
_fileSystem.WriteAllText(target + ".ver", package.versionStr);
|
File.WriteAllText(target + ".ver", package.versionStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
|
|
|
@ -169,7 +169,7 @@ namespace MediaBrowser.Api
|
||||||
{
|
{
|
||||||
var file = Path.Combine(path, Guid.NewGuid().ToString());
|
var file = Path.Combine(path, Guid.NewGuid().ToString());
|
||||||
|
|
||||||
_fileSystem.WriteAllText(file, string.Empty);
|
File.WriteAllText(file, string.Empty);
|
||||||
_fileSystem.DeleteFile(file);
|
_fileSystem.DeleteFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,7 @@ namespace MediaBrowser.Api.Images
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
contentPath = _fileSystem.ReadAllText(pointerCachePath);
|
contentPath = File.ReadAllText(pointerCachePath);
|
||||||
|
|
||||||
if (File.Exists(contentPath))
|
if (File.Exists(contentPath))
|
||||||
{
|
{
|
||||||
|
@ -239,7 +239,7 @@ namespace MediaBrowser.Api.Images
|
||||||
await DownloadImage(request.ImageUrl, urlHash, pointerCachePath).ConfigureAwait(false);
|
await DownloadImage(request.ImageUrl, urlHash, pointerCachePath).ConfigureAwait(false);
|
||||||
|
|
||||||
// Read the pointer file again
|
// Read the pointer file again
|
||||||
contentPath = _fileSystem.ReadAllText(pointerCachePath);
|
contentPath = File.ReadAllText(pointerCachePath);
|
||||||
|
|
||||||
return await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false);
|
return await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ namespace MediaBrowser.Api.Images
|
||||||
}
|
}
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath));
|
Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath));
|
||||||
_fileSystem.WriteAllText(pointerCachePath, fullCachePath);
|
File.WriteAllText(pointerCachePath, fullCachePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -265,7 +265,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
contentPath = _fileSystem.ReadAllText(pointerCachePath);
|
contentPath = File.ReadAllText(pointerCachePath);
|
||||||
|
|
||||||
if (File.Exists(contentPath))
|
if (File.Exists(contentPath))
|
||||||
{
|
{
|
||||||
|
@ -284,7 +284,7 @@ namespace MediaBrowser.Api
|
||||||
await DownloadImage(request.ProviderName, request.ImageUrl, urlHash, pointerCachePath).ConfigureAwait(false);
|
await DownloadImage(request.ProviderName, request.ImageUrl, urlHash, pointerCachePath).ConfigureAwait(false);
|
||||||
|
|
||||||
// Read the pointer file again
|
// Read the pointer file again
|
||||||
contentPath = _fileSystem.ReadAllText(pointerCachePath);
|
contentPath = File.ReadAllText(pointerCachePath);
|
||||||
|
|
||||||
return await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false);
|
return await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@ -315,7 +315,7 @@ namespace MediaBrowser.Api
|
||||||
}
|
}
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath));
|
Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath));
|
||||||
_fileSystem.WriteAllText(pointerCachePath, fullCachePath);
|
File.WriteAllText(pointerCachePath, fullCachePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -458,7 +458,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var text = FileSystem.ReadAllText(playlistPath, Encoding.UTF8);
|
var text = File.ReadAllText(playlistPath, Encoding.UTF8);
|
||||||
|
|
||||||
// If it appears in the playlist, it's done
|
// If it appears in the playlist, it's done
|
||||||
if (text.IndexOf(segmentFilename, StringComparison.OrdinalIgnoreCase) != -1)
|
if (text.IndexOf(segmentFilename, StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
|
|
|
@ -747,7 +747,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||||
}
|
}
|
||||||
if (protocol == MediaProtocol.File)
|
if (protocol == MediaProtocol.File)
|
||||||
{
|
{
|
||||||
return _fileSystem.ReadAllBytes(path);
|
return File.ReadAllBytes(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(protocol));
|
throw new ArgumentOutOfRangeException(nameof(protocol));
|
||||||
|
|
|
@ -296,7 +296,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
|
|
||||||
private XmlReader GetXmlReader(FileSystemMetadata xmlFile)
|
private XmlReader GetXmlReader(FileSystemMetadata xmlFile)
|
||||||
{
|
{
|
||||||
return GetXmlReader(_fileSystem.ReadAllText(xmlFile.FullName, Encoding.UTF8));
|
return GetXmlReader(File.ReadAllText(xmlFile.FullName, Encoding.UTF8));
|
||||||
}
|
}
|
||||||
|
|
||||||
private XmlReader GetXmlReader(string xml)
|
private XmlReader GetXmlReader(string xml)
|
||||||
|
|
|
@ -95,7 +95,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find out the last time we queried tvdb for updates
|
// Find out the last time we queried tvdb for updates
|
||||||
var lastUpdateTime = timestampFileInfo.Exists ? _fileSystem.ReadAllText(timestampFile, Encoding.UTF8) : string.Empty;
|
var lastUpdateTime = timestampFileInfo.Exists ? File.ReadAllText(timestampFile, Encoding.UTF8) : string.Empty;
|
||||||
|
|
||||||
string newUpdateTime;
|
string newUpdateTime;
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
await UpdateSeries(listToUpdate, path, nullableUpdateValue, progress, cancellationToken).ConfigureAwait(false);
|
await UpdateSeries(listToUpdate, path, nullableUpdateValue, progress, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
_fileSystem.WriteAllText(timestampFile, newUpdateTime, Encoding.UTF8);
|
File.WriteAllText(timestampFile, newUpdateTime, Encoding.UTF8);
|
||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue