diff --git a/NzbDrone.Core/Helpers/FileSizeFormatHelpercs.cs b/NzbDrone.Core/Helpers/FileSizeFormatHelpercs.cs
new file mode 100644
index 000000000..ccad15227
--- /dev/null
+++ b/NzbDrone.Core/Helpers/FileSizeFormatHelpercs.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace NzbDrone.Core.Helpers
+{
+ public class FileSizeFormatHelper
+ {
+ private const Decimal OneKiloByte = 1024M;
+ private const Decimal OneMegaByte = OneKiloByte * 1024M;
+ private const Decimal OneGigaByte = OneMegaByte * 1024M;
+
+ public static string Format(long bytes, int precision)
+ {
+ if (bytes == 0)
+ return "0B";
+
+ decimal size = Convert.ToDecimal(bytes);
+
+ string suffix;
+
+ if (size > OneGigaByte)
+ {
+ size /= OneGigaByte;
+ suffix = "GB";
+ }
+
+ else if (size > OneMegaByte)
+ {
+ size /= OneMegaByte;
+ suffix = "MB";
+ }
+
+ else if (size > OneKiloByte)
+ {
+ size /= OneKiloByte;
+ suffix = "KB";
+ }
+
+ else
+ {
+ suffix = " B";
+ }
+
+ return String.Format("{0:N" + precision + "}{1}", size, suffix);
+ }
+ }
+}
diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj
index 9532a4d4a..daee93be9 100644
--- a/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/NzbDrone.Core/NzbDrone.Core.csproj
@@ -167,6 +167,7 @@
+
diff --git a/NzbDrone.Core/Providers/Core/DiskProvider.cs b/NzbDrone.Core/Providers/Core/DiskProvider.cs
index 436800c47..5ce87f840 100644
--- a/NzbDrone.Core/Providers/Core/DiskProvider.cs
+++ b/NzbDrone.Core/Providers/Core/DiskProvider.cs
@@ -1,5 +1,7 @@
using System;
+using System.Collections.Generic;
using System.IO;
+using System.Linq;
namespace NzbDrone.Core.Providers.Core
{
@@ -56,5 +58,20 @@ namespace NzbDrone.Core.Providers.Core
{
Directory.Delete(path, recursive);
}
+
+ public virtual DateTime DirectoryDateCreated(string path)
+ {
+ return Directory.GetCreationTime(path);
+ }
+
+ public virtual IEnumerable GetFileInfos(string path, string pattern, SearchOption searchOption)
+ {
+ return new DirectoryInfo(path).GetFiles(pattern, searchOption);
+ }
+
+ public virtual void MoveDirectory(string source, string destination)
+ {
+ Directory.Move(source, destination);
+ }
}
}
\ No newline at end of file
diff --git a/NzbDrone.Web/Controllers/SystemController.cs b/NzbDrone.Web/Controllers/SystemController.cs
index 36ea3713c..f31f3db6e 100644
--- a/NzbDrone.Web/Controllers/SystemController.cs
+++ b/NzbDrone.Web/Controllers/SystemController.cs
@@ -1,7 +1,12 @@
-using System.Web.Mvc;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Web.Mvc;
+using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.Jobs;
+using NzbDrone.Web.Models;
using Telerik.Web.Mvc;
namespace NzbDrone.Web.Controllers
@@ -11,12 +16,14 @@ namespace NzbDrone.Web.Controllers
private readonly JobProvider _jobProvider;
private readonly IndexerProvider _indexerProvider;
private readonly ConfigProvider _configProvider;
+ private readonly DiskProvider _diskProvider;
- public SystemController(JobProvider jobProvider, IndexerProvider indexerProvider, ConfigProvider configProvider)
+ public SystemController(JobProvider jobProvider, IndexerProvider indexerProvider, ConfigProvider configProvider, DiskProvider diskProvider)
{
_jobProvider = jobProvider;
_indexerProvider = indexerProvider;
_configProvider = configProvider;
+ _diskProvider = diskProvider;
}
public ActionResult Jobs()
@@ -58,5 +65,64 @@ namespace NzbDrone.Web.Controllers
_configProvider.SetValue(key, value);
return View(new GridModel(_configProvider.All()));
}
+
+ //PostDownloadView
+ public ActionResult PendingProcessing()
+ {
+ ViewData["DropDir"] = _configProvider.SabDropDirectory;
+ return View();
+ }
+
+ [GridAction]
+ public ActionResult _PendingProcessingAjaxBinding()
+ {
+ var dropDir = _configProvider.SabDropDirectory;
+ var subFolders = _diskProvider.GetDirectories(dropDir);
+
+ var models = new List();
+
+ //Get the CreationTime and Files
+ foreach (var folder in subFolders)
+ {
+ var model = new PendingProcessingModel();
+ model.Name = new DirectoryInfo(folder).Name;
+ model.Created = _diskProvider.DirectoryDateCreated(folder);
+ model.Path = folder.Replace(Path.DirectorySeparatorChar, '|').Replace(Path.VolumeSeparatorChar, '^').Replace('\'', '`');
+
+ var files = _diskProvider.GetFileInfos(folder, "*.*", SearchOption.AllDirectories);
+
+ var fileResult = "";
+
+ foreach (var fileInfo in files)
+ {
+ fileResult += String.Format("", fileInfo.Name,
+ FileSizeFormatHelper.Format(fileInfo.Length, 1));
+ }
+
+ model.Files = fileResult;
+
+ models.Add(model);
+ }
+
+ return View(new GridModel(models));
+ }
+
+ public JsonResult RenamePendingProcessing(string path)
+ {
+ path = path.Replace('|', Path.DirectorySeparatorChar).Replace('^', Path.VolumeSeparatorChar).Replace('`', '\'');
+
+ var di = new DirectoryInfo(path);
+ var dropDir = di.Parent.FullName;
+ var folder = di.Name;
+
+ if (!folder.StartsWith("_UNPACK_") && !folder.StartsWith("_FAILED_"))
+ return new JsonResult { Data = "no change" };
+
+ folder = folder.Substring(8);
+ var newPath = dropDir + Path.DirectorySeparatorChar + folder;
+ _diskProvider.MoveDirectory(path, newPath);
+
+ return new JsonResult { Data = "ok" };
+ }
}
}
diff --git a/NzbDrone.Web/Models/PendingProcessingModel.cs b/NzbDrone.Web/Models/PendingProcessingModel.cs
new file mode 100644
index 000000000..8d9718f84
--- /dev/null
+++ b/NzbDrone.Web/Models/PendingProcessingModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace NzbDrone.Web.Models
+{
+ public class PendingProcessingModel
+ {
+ public string Name { get; set; }
+ public string Files { get; set; }
+ public DateTime Created { get; set; }
+ public string Path { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj
index 4ceff1bfc..4b3ba59be 100644
--- a/NzbDrone.Web/NzbDrone.Web.csproj
+++ b/NzbDrone.Web/NzbDrone.Web.csproj
@@ -259,6 +259,7 @@
+
@@ -897,6 +898,9 @@
+
+
+