aboutsummaryrefslogtreecommitdiff
path: root/Emby.IsoMounting/IsoMounter
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.IsoMounting/IsoMounter')
-rw-r--r--Emby.IsoMounting/IsoMounter/Configuration/PluginConfiguration.cs4
-rw-r--r--Emby.IsoMounting/IsoMounter/IsoMounter.csproj2
-rw-r--r--Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs96
-rw-r--r--Emby.IsoMounting/IsoMounter/LinuxMount.cs6
-rw-r--r--Emby.IsoMounting/IsoMounter/Plugin.cs24
-rw-r--r--Emby.IsoMounting/IsoMounter/Properties/AssemblyInfo.cs2
6 files changed, 72 insertions, 62 deletions
diff --git a/Emby.IsoMounting/IsoMounter/Configuration/PluginConfiguration.cs b/Emby.IsoMounting/IsoMounter/Configuration/PluginConfiguration.cs
index 9308b8c89..4755e4e82 100644
--- a/Emby.IsoMounting/IsoMounter/Configuration/PluginConfiguration.cs
+++ b/Emby.IsoMounting/IsoMounter/Configuration/PluginConfiguration.cs
@@ -1,8 +1,8 @@
-using MediaBrowser.Model.Plugins;
+using MediaBrowser.Model.Plugins;
namespace IsoMounter.Configuration
{
public class PluginConfiguration : BasePluginConfiguration
{
}
-} \ No newline at end of file
+}
diff --git a/Emby.IsoMounting/IsoMounter/IsoMounter.csproj b/Emby.IsoMounting/IsoMounter/IsoMounter.csproj
index 9274f9763..2a81f5aa0 100644
--- a/Emby.IsoMounting/IsoMounter/IsoMounter.csproj
+++ b/Emby.IsoMounting/IsoMounter/IsoMounter.csproj
@@ -8,7 +8,7 @@
<ProjectReference Include="..\..\MediaBrowser.Model\MediaBrowser.Model.csproj" />
<ProjectReference Include="..\..\MediaBrowser.Common\MediaBrowser.Common.csproj" />
</ItemGroup>
-
+
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
diff --git a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs
index ab85cb721..ac486f167 100644
--- a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs
+++ b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs
@@ -1,19 +1,19 @@
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
{
public class LinuxIsoManager : IIsoMounter
{
[DllImport("libc", SetLastError = true)]
- public static extern uint getuid();
+ static extern uint getuid();
#region Private Fields
@@ -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,21 +102,11 @@ namespace IsoMounter
#region Interface Implementation for IIsoMounter
- public bool IsInstalled {
- get {
- return true;
- }
- }
+ public bool IsInstalled => true;
- public string Name {
- get { return "LinuxMount"; }
- }
+ public string Name => "LinuxMount";
- public bool RequiresInstallation {
- get {
- return false;
- }
- }
+ public bool RequiresInstallation => false;
public bool CanMount(string path)
{
@@ -148,10 +141,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 +175,8 @@ namespace IsoMounter
protected virtual void Dispose(bool disposing)
{
- if (disposed) {
+ if (disposed)
+ {
return;
}
@@ -190,7 +186,8 @@ namespace IsoMounter
disposing.ToString()
);
- if (disposing) {
+ if (disposing)
+ {
//
// Free managed objects here.
@@ -217,7 +214,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 +245,8 @@ namespace IsoMounter
bool processFailed = false;
var process = ProcessFactory.Create(
- new ProcessOptions {
+ new ProcessOptions
+ {
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
@@ -285,9 +284,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 +302,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 +317,9 @@ namespace IsoMounter
mountPoint
);
- } else {
+ }
+ else
+ {
throw new ArgumentNullException(nameof(isoPath));
@@ -333,10 +338,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 +356,8 @@ namespace IsoMounter
cmdArguments
);
- if (ExecuteCommand(cmdFilename, cmdArguments)) {
+ if (ExecuteCommand(cmdFilename, cmdArguments))
+ {
_logger.LogInformation(
"[{0}] ISO mount completed successfully.",
@@ -357,7 +366,9 @@ namespace IsoMounter
mountedISO = new LinuxMount(this, isoPath, mountPoint);
- } else {
+ }
+ else
+ {
_logger.LogInformation(
"[{0}] ISO mount completed with errors.",
@@ -387,7 +398,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 +408,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 +434,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..f45b39d3e 100644
--- a/Emby.IsoMounting/IsoMounter/Plugin.cs
+++ b/Emby.IsoMounting/IsoMounter/Plugin.cs
@@ -1,8 +1,8 @@
-using MediaBrowser.Common.Configuration;
-using MediaBrowser.Common.Plugins;
-using MediaBrowser.Model.Serialization;
using System;
using IsoMounter.Configuration;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Plugins;
+using MediaBrowser.Model.Serialization;
namespace IsoMounter
{
@@ -13,30 +13,18 @@ namespace IsoMounter
}
private Guid _id = new Guid("4682DD4C-A675-4F1B-8E7C-79ADF137A8F8");
- public override Guid Id
- {
- get { return _id; }
- }
+ public override Guid Id => _id;
/// <summary>
/// Gets the name of the plugin
/// </summary>
/// <value>The name.</value>
- public override string Name
- {
- get { return "Iso Mounter"; }
- }
+ public override string Name => "Iso Mounter";
/// <summary>
/// Gets the description.
/// </summary>
/// <value>The description.</value>
- public override string Description
- {
- get
- {
- return "Mount and stream ISO contents";
- }
- }
+ public override string Description => "Mount and stream ISO contents";
}
}
diff --git a/Emby.IsoMounting/IsoMounter/Properties/AssemblyInfo.cs b/Emby.IsoMounting/IsoMounter/Properties/AssemblyInfo.cs
index 8a26b12a2..d60eccc2e 100644
--- a/Emby.IsoMounting/IsoMounter/Properties/AssemblyInfo.cs
+++ b/Emby.IsoMounting/IsoMounter/Properties/AssemblyInfo.cs
@@ -2,7 +2,7 @@ using System.Reflection;
using System.Resources;
using System.Runtime.InteropServices;
-// General Information about an assembly is controlled through the following
+// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("IsoMounter")]