diff options
| author | Erwin de Haan <EraYaN@users.noreply.github.com> | 2019-01-13 20:17:15 +0100 |
|---|---|---|
| committer | Erwin de Haan <EraYaN@users.noreply.github.com> | 2019-01-13 20:17:15 +0100 |
| commit | 25a428373c93d398ed19b177c12879106593444a (patch) | |
| tree | 2d5d4ae78b7d88d255b4d6710a193a7cf5c6301a /Emby.IsoMounting | |
| parent | 009c95d97294f013c1be6279590c91c1f1cd216b (diff) | |
Visual Studio Reformat: Emby.IsoMounting
Diffstat (limited to 'Emby.IsoMounting')
| -rw-r--r-- | Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs | 93 | ||||
| -rw-r--r-- | Emby.IsoMounting/IsoMounter/LinuxMount.cs | 6 | ||||
| -rw-r--r-- | Emby.IsoMounting/IsoMounter/Plugin.cs | 6 |
3 files changed, 71 insertions, 34 deletions
diff --git a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs index ab85cb721..846f3b2ce 100644 --- a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs +++ b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs @@ -1,12 +1,12 @@ using System; using System.IO; +using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.Diagnostics; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.System; -using System.Runtime.InteropServices; +using Microsoft.Extensions.Logging; namespace IsoMounter { @@ -87,9 +87,12 @@ namespace IsoMounter UmountCommand ); - if (!string.IsNullOrEmpty(SudoCommand) && !string.IsNullOrEmpty(MountCommand) && !string.IsNullOrEmpty(UmountCommand)) { + if (!string.IsNullOrEmpty(SudoCommand) && !string.IsNullOrEmpty(MountCommand) && !string.IsNullOrEmpty(UmountCommand)) + { ExecutablesAvailable = true; - } else { + } + else + { ExecutablesAvailable = false; } @@ -99,18 +102,23 @@ namespace IsoMounter #region Interface Implementation for IIsoMounter - public bool IsInstalled { - get { + public bool IsInstalled + { + get + { return true; } } - public string Name { + public string Name + { get { return "LinuxMount"; } } - public bool RequiresInstallation { - get { + public bool RequiresInstallation + { + get + { return false; } } @@ -148,10 +156,12 @@ namespace IsoMounter public Task<IIsoMount> Mount(string isoPath, CancellationToken cancellationToken) { - if (MountISO(isoPath, out LinuxMount mountedISO)) { + if (MountISO(isoPath, out LinuxMount mountedISO)) + { return Task.FromResult<IIsoMount>(mountedISO); } - else { + else + { throw new IOException(string.Format( "An error occurred trying to mount image [$0].", isoPath @@ -180,7 +190,8 @@ namespace IsoMounter protected virtual void Dispose(bool disposing) { - if (disposed) { + if (disposed) + { return; } @@ -190,7 +201,8 @@ namespace IsoMounter disposing.ToString() ); - if (disposing) { + if (disposing) + { // // Free managed objects here. @@ -217,7 +229,8 @@ namespace IsoMounter { string path = test.Trim(); - if (!string.IsNullOrEmpty(path) && FileSystem.FileExists(path = Path.Combine(path, name))) { + if (!string.IsNullOrEmpty(path) && FileSystem.FileExists(path = Path.Combine(path, name))) + { return FileSystem.GetFullPath(path); } } @@ -247,7 +260,8 @@ namespace IsoMounter bool processFailed = false; var process = ProcessFactory.Create( - new ProcessOptions { + new ProcessOptions + { CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true, @@ -285,9 +299,12 @@ namespace IsoMounter _logger.LogDebug(ex, "[{Name}] Unhandled exception executing command.", Name); } - if (!processFailed && process.ExitCode == 0) { + if (!processFailed && process.ExitCode == 0) + { return true; - } else { + } + else + { return false; } @@ -300,7 +317,8 @@ namespace IsoMounter string cmdFilename; string mountPoint = Path.Combine(MountPointRoot, Guid.NewGuid().ToString()); - if (!string.IsNullOrEmpty(isoPath)) { + if (!string.IsNullOrEmpty(isoPath)) + { _logger.LogInformation( "[{Name}] Attempting to mount [{Path}].", @@ -314,7 +332,9 @@ namespace IsoMounter mountPoint ); - } else { + } + else + { throw new ArgumentNullException(nameof(isoPath)); @@ -333,10 +353,13 @@ namespace IsoMounter throw new IOException("Unable to create mount point for " + isoPath); } - if (GetUID() == 0) { + if (GetUID() == 0) + { cmdFilename = MountCommand; cmdArguments = string.Format("\"{0}\" \"{1}\"", isoPath, mountPoint); - } else { + } + else + { cmdFilename = SudoCommand; cmdArguments = string.Format("\"{0}\" \"{1}\" \"{2}\"", MountCommand, isoPath, mountPoint); } @@ -348,7 +371,8 @@ namespace IsoMounter cmdArguments ); - if (ExecuteCommand(cmdFilename, cmdArguments)) { + if (ExecuteCommand(cmdFilename, cmdArguments)) + { _logger.LogInformation( "[{0}] ISO mount completed successfully.", @@ -357,7 +381,9 @@ namespace IsoMounter mountedISO = new LinuxMount(this, isoPath, mountPoint); - } else { + } + else + { _logger.LogInformation( "[{0}] ISO mount completed with errors.", @@ -387,7 +413,8 @@ namespace IsoMounter string cmdArguments; string cmdFilename; - if (mount != null) { + if (mount != null) + { _logger.LogInformation( "[{0}] Attempting to unmount ISO [{1}] mounted on [{2}].", @@ -396,16 +423,21 @@ namespace IsoMounter mount.MountedPath ); - } else { + } + else + { throw new ArgumentNullException(nameof(mount)); } - if (GetUID() == 0) { + if (GetUID() == 0) + { cmdFilename = UmountCommand; cmdArguments = string.Format("\"{0}\"", mount.MountedPath); - } else { + } + else + { cmdFilename = SudoCommand; cmdArguments = string.Format("\"{0}\" \"{1}\"", UmountCommand, mount.MountedPath); } @@ -417,14 +449,17 @@ namespace IsoMounter cmdArguments ); - if (ExecuteCommand(cmdFilename, cmdArguments)) { + if (ExecuteCommand(cmdFilename, cmdArguments)) + { _logger.LogInformation( "[{0}] ISO unmount completed successfully.", Name ); - } else { + } + else + { _logger.LogInformation( "[{0}] ISO unmount completed with errors.", diff --git a/Emby.IsoMounting/IsoMounter/LinuxMount.cs b/Emby.IsoMounting/IsoMounter/LinuxMount.cs index da2eb1983..b8636822b 100644 --- a/Emby.IsoMounting/IsoMounter/LinuxMount.cs +++ b/Emby.IsoMounting/IsoMounter/LinuxMount.cs @@ -45,11 +45,13 @@ namespace IsoMounter protected virtual void Dispose(bool disposing) { - if (disposed) { + if (disposed) + { return; } - if (disposing) { + if (disposing) + { // // Free managed objects here. diff --git a/Emby.IsoMounting/IsoMounter/Plugin.cs b/Emby.IsoMounting/IsoMounter/Plugin.cs index ea5317502..6a2431393 100644 --- a/Emby.IsoMounting/IsoMounter/Plugin.cs +++ b/Emby.IsoMounting/IsoMounter/Plugin.cs @@ -1,8 +1,8 @@ -using MediaBrowser.Common.Configuration; +using System; +using IsoMounter.Configuration; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Plugins; using MediaBrowser.Model.Serialization; -using System; -using IsoMounter.Configuration; namespace IsoMounter { |
