aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/EnvironmentService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Api/EnvironmentService.cs')
-rw-r--r--MediaBrowser.Api/EnvironmentService.cs44
1 files changed, 14 insertions, 30 deletions
diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs
index b354cb26c..bab538c91 100644
--- a/MediaBrowser.Api/EnvironmentService.cs
+++ b/MediaBrowser.Api/EnvironmentService.cs
@@ -2,13 +2,11 @@
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Net;
-using ServiceStack;
using System;
using System.Collections.Generic;
-using System.Globalization;
using System.IO;
using System.Linq;
-using CommonIO;
+using MediaBrowser.Model.Services;
namespace MediaBrowser.Api
{
@@ -108,6 +106,7 @@ namespace MediaBrowser.Api
public class EnvironmentService : BaseApiService
{
const char UncSeparator = '\\';
+ const string UncSeparatorString = "\\";
/// <summary>
/// The _network manager
@@ -134,20 +133,17 @@ namespace MediaBrowser.Api
{
var result = new DefaultDirectoryBrowserInfo();
- if (Environment.OSVersion.Platform == PlatformID.Unix)
+ try
{
- try
+ var qnap = "/share/CACHEDEV1_DATA";
+ if (_fileSystem.DirectoryExists(qnap))
{
- var qnap = "/share/CACHEDEV1_DATA";
- if (Directory.Exists(qnap))
- {
- result.Path = qnap;
- }
+ result.Path = qnap;
}
- catch
- {
+ }
+ catch
+ {
- }
}
return ToOptimizedResult(result);
@@ -167,7 +163,7 @@ namespace MediaBrowser.Api
throw new ArgumentNullException("Path");
}
- var networkPrefix = UncSeparator.ToString(CultureInfo.InvariantCulture) + UncSeparator.ToString(CultureInfo.InvariantCulture);
+ var networkPrefix = UncSeparatorString + UncSeparatorString;
if (path.StartsWith(networkPrefix, StringComparison.OrdinalIgnoreCase) && path.LastIndexOf(UncSeparator) == 1)
{
@@ -204,13 +200,11 @@ namespace MediaBrowser.Api
/// <returns>IEnumerable{FileSystemEntryInfo}.</returns>
private IEnumerable<FileSystemEntryInfo> 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 FileSystemEntryInfo
+ return _fileSystem.GetDrives().Select(d => new FileSystemEntryInfo
{
- Name = GetName(d),
- Path = d.RootDirectory.FullName,
+ Name = d.Name,
+ Path = d.FullName,
Type = FileSystemEntryType.Directory
-
});
}
@@ -229,16 +223,6 @@ namespace MediaBrowser.Api
}
/// <summary>
- /// Gets the name.
- /// </summary>
- /// <param name="drive">The drive.</param>
- /// <returns>System.String.</returns>
- private string GetName(DriveInfo drive)
- {
- return drive.Name;
- }
-
- /// <summary>
/// Gets the network shares.
/// </summary>
/// <param name="path">The path.</param>
@@ -263,7 +247,7 @@ namespace MediaBrowser.Api
// using EnumerateFileSystemInfos doesn't handle reparse points (symlinks)
var entries = _fileSystem.GetFileSystemEntries(request.Path).Where(i =>
{
- if (!request.IncludeHidden && i.Attributes.HasFlag(FileAttributes.Hidden))
+ if (!request.IncludeHidden && i.IsHidden)
{
return false;
}