From 68788047056584b157596775619afb26aa9c258e Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 20 Dec 2014 13:24:29 -0800 Subject: [PATCH] Fixed: File browser ordering and volume name --- src/NzbDrone.Common/Disk/DiskProviderBase.cs | 7 +++++++ .../Disk/FileSystemLookupService.cs | 18 +++++++++++++++--- src/NzbDrone.Common/Disk/IDiskProvider.cs | 1 + .../Shared/FileBrowser/FileBrowserTypeCell.js | 4 ++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Common/Disk/DiskProviderBase.cs b/src/NzbDrone.Common/Disk/DiskProviderBase.cs index c858f417b..f2b83226a 100644 --- a/src/NzbDrone.Common/Disk/DiskProviderBase.cs +++ b/src/NzbDrone.Common/Disk/DiskProviderBase.cs @@ -431,6 +431,13 @@ namespace NzbDrone.Common.Disk return new FileStream(path, FileMode.Open, FileAccess.Read); } + public List GetDrives() + { + return DriveInfo.GetDrives() + .Where(d => d.DriveType == DriveType.Fixed || d.DriveType == DriveType.Network) + .ToList(); + } + public List GetDirectoryInfos(string path) { Ensure.That(path, () => path).IsValidPath(); diff --git a/src/NzbDrone.Common/Disk/FileSystemLookupService.cs b/src/NzbDrone.Common/Disk/FileSystemLookupService.cs index b5b7db9b6..d5466f803 100644 --- a/src/NzbDrone.Common/Disk/FileSystemLookupService.cs +++ b/src/NzbDrone.Common/Disk/FileSystemLookupService.cs @@ -103,12 +103,12 @@ namespace NzbDrone.Common.Disk private List GetDrives() { - return _diskProvider.GetFixedDrives() + return _diskProvider.GetDrives() .Select(d => new FileSystemModel { Type = FileSystemEntityType.Drive, - Name = d, - Path = d, + Name = GetVolumeName(d), + Path = d.Name, LastModified = null }) .ToList(); @@ -117,6 +117,7 @@ namespace NzbDrone.Common.Disk private List GetDirectories(string path) { var directories = _diskProvider.GetDirectoryInfos(path) + .OrderBy(d => d.Name) .Select(d => new FileSystemModel { Name = d.Name, @@ -134,6 +135,7 @@ namespace NzbDrone.Common.Disk private List GetFiles(string path) { return _diskProvider.GetFileInfos(path) + .OrderBy(d => d.Name) .Select(d => new FileSystemModel { Name = d.Name, @@ -155,6 +157,16 @@ namespace NzbDrone.Common.Disk return path; } + + private string GetVolumeName(DriveInfo driveInfo) + { + if (driveInfo.VolumeLabel.IsNullOrWhiteSpace()) + { + return driveInfo.Name; + } + + return String.Format("{0} ({1})", driveInfo.Name, driveInfo.VolumeLabel); + } private string GetParent(string path) { diff --git a/src/NzbDrone.Common/Disk/IDiskProvider.cs b/src/NzbDrone.Common/Disk/IDiskProvider.cs index 950c005db..1024dfba5 100644 --- a/src/NzbDrone.Common/Disk/IDiskProvider.cs +++ b/src/NzbDrone.Common/Disk/IDiskProvider.cs @@ -46,6 +46,7 @@ namespace NzbDrone.Common.Disk string[] GetFixedDrives(); string GetVolumeLabel(string path); FileStream StreamFile(string path); + List GetDrives(); List GetDirectoryInfos(string path); List GetFileInfos(string path); } diff --git a/src/UI/Shared/FileBrowser/FileBrowserTypeCell.js b/src/UI/Shared/FileBrowser/FileBrowserTypeCell.js index de90dd2d1..72f3ddbd5 100644 --- a/src/UI/Shared/FileBrowser/FileBrowserTypeCell.js +++ b/src/UI/Shared/FileBrowser/FileBrowserTypeCell.js @@ -24,11 +24,11 @@ define( } else if (type === 'folder') { - icon = 'icon-folder-close'; + icon = 'icon-folder-close-alt'; } else if (type === 'file') { - icon = 'icon-file'; + icon = 'icon-file-alt'; } this.$el.html(''.format(icon));