diff options
| author | Joshua M. Boniface <joshua@boniface.me> | 2019-08-19 14:57:48 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-19 14:57:48 -0400 |
| commit | d95c04787cc4486f4ea5caaef20f6ac407a3f84a (patch) | |
| tree | 7e3193614c5a132ae63034c2bb7e07956a5670e6 /Emby.Server.Implementations/IO | |
| parent | 3ba709fcc32d7255a2cb2466dde8c2479130a2bc (diff) | |
| parent | d99278da1dcac4d3c60739e864597aa01f916636 (diff) | |
Merge branch 'master' into h265
Diffstat (limited to 'Emby.Server.Implementations/IO')
| -rw-r--r-- | Emby.Server.Implementations/IO/IsoManager.cs | 26 | ||||
| -rw-r--r-- | Emby.Server.Implementations/IO/ManagedFileSystem.cs | 19 |
2 files changed, 17 insertions, 28 deletions
diff --git a/Emby.Server.Implementations/IO/IsoManager.cs b/Emby.Server.Implementations/IO/IsoManager.cs index f0a15097c..94e92c2a6 100644 --- a/Emby.Server.Implementations/IO/IsoManager.cs +++ b/Emby.Server.Implementations/IO/IsoManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -8,12 +9,12 @@ using MediaBrowser.Model.IO; namespace Emby.Server.Implementations.IO { /// <summary> - /// Class IsoManager + /// Class IsoManager. /// </summary> public class IsoManager : IIsoManager { /// <summary> - /// The _mounters + /// The _mounters. /// </summary> private readonly List<IIsoMounter> _mounters = new List<IIsoMounter>(); @@ -22,9 +23,7 @@ namespace Emby.Server.Implementations.IO /// </summary> /// <param name="isoPath">The iso path.</param> /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>IsoMount.</returns> - /// <exception cref="ArgumentNullException">isoPath</exception> - /// <exception cref="ArgumentException"></exception> + /// <returns><see creaf="IsoMount" />.</returns> public Task<IIsoMount> Mount(string isoPath, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(isoPath)) @@ -36,7 +35,11 @@ namespace Emby.Server.Implementations.IO if (mounter == null) { - throw new ArgumentException(string.Format("No mounters are able to mount {0}", isoPath)); + throw new ArgumentException( + string.Format( + CultureInfo.InvariantCulture, + "No mounters are able to mount {0}", + isoPath)); } return mounter.Mount(isoPath, cancellationToken); @@ -60,16 +63,5 @@ namespace Emby.Server.Implementations.IO { _mounters.AddRange(mounters); } - - /// <summary> - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// </summary> - public void Dispose() - { - foreach (var mounter in _mounters) - { - mounter.Dispose(); - } - } } } diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs index 0dea5041a..ae8371a32 100644 --- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Diagnostics; using System.IO; using System.Linq; @@ -20,16 +21,14 @@ namespace Emby.Server.Implementations.IO protected ILogger Logger; private readonly List<IShortcutHandler> _shortcutHandlers = new List<IShortcutHandler>(); - private readonly string _tempPath; - private readonly bool _isEnvironmentCaseInsensitive; public ManagedFileSystem( - ILoggerFactory loggerFactory, + ILogger<ManagedFileSystem> logger, IApplicationPaths applicationPaths) { - Logger = loggerFactory.CreateLogger("FileSystem"); + Logger = logger; _tempPath = applicationPaths.TempDirectory; _isEnvironmentCaseInsensitive = OperatingSystem.Id == OperatingSystemId.Windows; @@ -557,7 +556,7 @@ namespace Emby.Server.Implementations.IO throw new ArgumentNullException(nameof(file2)); } - var temp1 = Path.Combine(_tempPath, Guid.NewGuid().ToString("N")); + var temp1 = Path.Combine(_tempPath, Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture)); // Copying over will fail against hidden files SetHidden(file1, false); @@ -647,7 +646,6 @@ namespace Emby.Server.Implementations.IO public virtual bool IsPathFile(string path) { // Cannot use Path.IsPathRooted because it returns false under mono when using windows-based paths, e.g. C:\\ - if (path.IndexOf("://", StringComparison.OrdinalIgnoreCase) != -1 && !path.StartsWith("file://", StringComparison.OrdinalIgnoreCase)) { @@ -655,8 +653,6 @@ namespace Emby.Server.Implementations.IO } return true; - - //return Path.IsPathRooted(path); } public virtual void DeleteFile(string path) @@ -667,13 +663,14 @@ namespace Emby.Server.Implementations.IO public virtual List<FileSystemMetadata> GetDrives() { - // Only include drives in the ready state or this method could end up being very slow, waiting for drives to timeout - return DriveInfo.GetDrives().Where(d => d.IsReady).Select(d => new FileSystemMetadata + // check for ready state to avoid waiting for drives to timeout + // some drives on linux have no actual size or are used for other purposes + return DriveInfo.GetDrives().Where(d => d.IsReady && d.TotalSize != 0 && d.DriveType != DriveType.Ram) + .Select(d => new FileSystemMetadata { Name = d.Name, FullName = d.RootDirectory.FullName, IsDirectory = true - }).ToList(); } |
