Merge branch 'develop' of https://github.com/Taloth/NzbDrone into develop

pull/4/head
Mark McDowall 11 years ago
commit 7df5d6c9b8

@ -136,6 +136,23 @@ namespace NzbDrone.Common.Test
parentPath.IsParentPath(childPath).Should().Be(expectedResult);
}
[TestCase(@"C:\Test\mydir", @"C:\Test")]
[TestCase(@"C:\Test\", @"C:")]
[TestCase(@"C:\", null)]
public void path_should_return_parent(string path, string parentPath)
{
path.GetParentPath().Should().Be(parentPath);
}
[Test]
public void path_should_return_parent_for_oversized_path()
{
var path = @"/media/2e168617-f2ae-43fb-b88c-3663af1c8eea/downloads/sabnzbd/nzbdrone/Some.Real.Big.Thing/With.Alot.Of.Nested.Directories/Some.Real.Big.Thing/With.Alot.Of.Nested.Directories/Some.Real.Big.Thing/With.Alot.Of.Nested.Directories/Some.Real.Big.Thing/With.Alot.Of.Nested.Directories/Some.Real.Big.Thing/With.Alot.Of.Nested.Directories";
var parentPath = @"/media/2e168617-f2ae-43fb-b88c-3663af1c8eea/downloads/sabnzbd/nzbdrone/Some.Real.Big.Thing/With.Alot.Of.Nested.Directories/Some.Real.Big.Thing/With.Alot.Of.Nested.Directories/Some.Real.Big.Thing/With.Alot.Of.Nested.Directories/Some.Real.Big.Thing/With.Alot.Of.Nested.Directories/Some.Real.Big.Thing";
path.GetParentPath().Should().Be(parentPath);
}
[Test]
[Ignore]
public void should_not_be_parent_when_it_is_grandparent()

@ -53,6 +53,22 @@ namespace NzbDrone.Common
return childPath.Substring(parentPath.Length).Trim(Path.DirectorySeparatorChar);
}
public static string GetParentPath(this string childPath)
{
var parentPath = childPath.TrimEnd('\\', '/');
var index = parentPath.LastIndexOfAny(new[] { '\\', '/' });
if (index != -1)
{
return parentPath.Substring(0, index);
}
else
{
return null;
}
}
public static bool IsParentPath(this string parentPath, string childPath)
{
parentPath = parentPath.TrimEnd(Path.DirectorySeparatorChar);

@ -32,6 +32,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("0e895c37245186812cb08aab1529cf8ee389dd05.mkv")]
[TestCase("08bbc153931ce3ca5fcafe1b92d3297285feb061.mkv")]
[TestCase("185d86a343e39f3341e35c4dad3ff159")]
[TestCase("ah63jka93jf0jh26ahjas961.mkv")]
public void should_not_parse_crap(string title)
{
Parser.Parser.ParseTitle(title).Should().BeNull();

@ -161,10 +161,10 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
if (!sabHistoryItem.Storage.IsNullOrWhiteSpace())
{
var parent = Directory.GetParent(sabHistoryItem.Storage);
if (parent != null && parent.Name == sabHistoryItem.Title)
var parent = sabHistoryItem.Storage.GetParentPath();
if (parent != null && Path.GetFileName(parent) == sabHistoryItem.Title)
{
historyItem.OutputPath = parent.FullName;
historyItem.OutputPath = parent;
}
else
{

@ -77,7 +77,7 @@ namespace NzbDrone.Core.Download
{
trackedDownload.State = TrackedDownloadState.Imported;
_logger.Debug("Already added to history as imported: " + trackedDownload.DownloadItem.Title);
_logger.Trace("Already added to history as imported: " + trackedDownload.DownloadItem.Title);
}
else
{
@ -137,13 +137,13 @@ namespace NzbDrone.Core.Download
importedItems.First().Data[DownloadTrackingService.DOWNLOAD_CLIENT_ID] = grabbedItems.First().Data[DownloadTrackingService.DOWNLOAD_CLIENT_ID];
_historyService.UpdateHistoryData(importedItems.First().Id, importedItems.First().Data);
_logger.Debug("Storage path does not exist, but found probable drone factory ImportEvent: " + trackedDownload.DownloadItem.Title);
_logger.Trace("Storage path does not exist, but found probable drone factory ImportEvent: " + trackedDownload.DownloadItem.Title);
return;
}
}
}
_logger.Debug("Storage path does not exist: " + trackedDownload.DownloadItem.Title);
_logger.Trace("Storage path does not exist: " + trackedDownload.DownloadItem.Title);
return;
}
}

@ -54,7 +54,7 @@ namespace NzbDrone.Core.Download
if (!grabbedItems.Any())
{
_logger.Debug("Download was not grabbed by drone, ignoring.");
_logger.Trace("Download was not grabbed by drone, ignoring download: " + trackedDownload.DownloadItem.Title);
return;
}
@ -64,7 +64,7 @@ namespace NzbDrone.Core.Download
if (failedItems.Any())
{
_logger.Debug("Already added to history as failed");
_logger.Trace("Already added to history as failed: " + trackedDownload.DownloadItem.Title);
}
else
{
@ -78,7 +78,7 @@ namespace NzbDrone.Core.Download
if (!grabbedItems.Any())
{
_logger.Debug("Download was not grabbed by drone, ignoring.");
_logger.Trace("Download was not grabbed by drone, ignoring download: " + trackedDownload.DownloadItem.Title);
return;
}
@ -86,13 +86,13 @@ namespace NzbDrone.Core.Download
if (trackedDownload.DownloadItem.Message.Equals("Unpacking failed, write error or disk is full?",
StringComparison.InvariantCultureIgnoreCase))
{
_logger.Debug("Failed due to lack of disk space, do not blacklist");
_logger.Trace("Failed due to lack of disk space, do not blacklist: " + trackedDownload.DownloadItem.Title);
return;
}
if (FailedDownloadForRecentRelease(downloadClient, trackedDownload, grabbedItems))
{
_logger.Debug("Recent release Failed, do not blacklist");
_logger.Trace("Recent release Failed, do not blacklist: " + trackedDownload.DownloadItem.Title);
return;
}
@ -102,7 +102,7 @@ namespace NzbDrone.Core.Download
if (failedItems.Any())
{
_logger.Debug("Already added to history as failed");
_logger.Trace("Already added to history as failed: " + trackedDownload.DownloadItem.Title);
}
else
{
@ -110,6 +110,18 @@ namespace NzbDrone.Core.Download
}
}
if (trackedDownload.DownloadItem.Status != DownloadItemStatus.Failed && trackedDownload.State == TrackedDownloadState.Downloading)
{
var grabbedItems = GetHistoryItems(grabbedHistory, trackedDownload.DownloadItem.DownloadClientId);
var failedItems = GetHistoryItems(failedHistory, trackedDownload.DownloadItem.DownloadClientId);
if (grabbedItems.Any() && failedItems.Any())
{
_logger.Trace("Already added to history as failed, updating tracked state: " + trackedDownload.DownloadItem.Title);
trackedDownload.State = TrackedDownloadState.DownloadFailed;
}
}
if (_configService.RemoveFailedDownloads && trackedDownload.State == TrackedDownloadState.DownloadFailed)
{
try
@ -121,7 +133,7 @@ namespace NzbDrone.Core.Download
}
catch (NotSupportedException)
{
_logger.Debug("Removing item not supported by your download client");
_logger.Trace("Removing item not supported by your download client");
}
}
}
@ -132,25 +144,25 @@ namespace NzbDrone.Core.Download
if (!Double.TryParse(matchingHistoryItems.First().Data.GetValueOrDefault("ageHours"), out ageHours))
{
_logger.Debug("Unable to determine age of failed download");
_logger.Debug("Unable to determine age of failed download: " + trackedDownload.DownloadItem.Title);
return false;
}
if (ageHours > _configService.BlacklistGracePeriod)
{
_logger.Debug("Failed download is older than the grace period");
_logger.Debug("Failed download is older than the grace period: " + trackedDownload.DownloadItem.Title);
return false;
}
if (trackedDownload.RetryCount >= _configService.BlacklistRetryLimit)
{
_logger.Debug("Retry limit reached");
_logger.Debug("Retry limit reached: " + trackedDownload.DownloadItem.Title);
return false;
}
if (trackedDownload.RetryCount == 0 || trackedDownload.LastRetry.AddMinutes(_configService.BlacklistRetryInterval) < DateTime.UtcNow)
{
_logger.Debug("Retrying failed release");
_logger.Debug("Retrying failed release: " + trackedDownload.DownloadItem.Title);
trackedDownload.LastRetry = DateTime.UtcNow;
trackedDownload.RetryCount++;

@ -113,6 +113,9 @@ namespace NzbDrone.Core.Parser
// Generic match for md5 and mixed-case hashes.
new Regex(@"^[0-9a-zA-Z]{32}", RegexOptions.Compiled),
// Generic match for shorter lower-case hashes.
new Regex(@"^[a-z0-9]{24}$", RegexOptions.Compiled),
// Format seen on some NZBGeek releases
new Regex(@"^[A-Z]{11}\d{3}$", RegexOptions.Compiled)
};

@ -15,7 +15,7 @@ define(
templateHelpers: {
icalHttpUrl : window.location.protocol + '//' + window.location.host + StatusModel.get('urlBase') + '/feed/calendar/NzbDrone.ics?apikey=' + window.NzbDrone.ApiKey,
icalWebCalUrl : 'webcal://' + window.location.host + StatusModel.get('urlBase') + '/feed/calendar/NzbDrone.ics'
icalWebCalUrl : 'webcal://' + window.location.host + StatusModel.get('urlBase') + '/feed/calendar/NzbDrone.ics?apikey=' + window.NzbDrone.ApiKey
},
onShow: function () {

@ -5,29 +5,21 @@
<h3>NzbDrone Calendar feed</h3>
</div>
<div class="modal-body edit-series-modal">
<div class="row">
<div class="col-md-12">
<div class="form-horizontal">
<div class="form-group">
<label class="col-sm-3 control-label">iCal feed</label>
<div class="col-sm-1 col-sm-push-8 help-inline">
<i class="icon-nd-form-info" title="Copy this url into your clients subscription form or use the subscribe button if your browser support webcal"/>
<label class="col-sm-2 control-label">iCal feed</label>
<div class="col-sm-1 col-sm-push-9 help-inline">
<i class="icon-nd-form-info" title="Copy this url into your clients subscription form or use the subscribe button if your browser support webcal" />
</div>
<div class="col-sm-8 col-sm-pull-1">
<div class="col-sm-9 col-sm-pull-1">
<div class="input-group ical-url">
<input type="text" class="form-control x-ical-url" value="{{icalHttpUrl}}" readonly="readonly" />
<div class="input-group-btn">
<button class="btn btn-icon-only x-ical-copy" title="Copy to clipboard"><i class="icon-copy"></i></button>
<button class="btn btn-icon-only no-router"><a title="Subscribe" href="{{icalWebCalUrl}}" target="_blank"><i class="icon-calendar-empty"></i></a></button>
<button class="btn btn-icon-only no-router" title="Subscribe" href="{{icalWebCalUrl}}" target="_blank" data-container=".modal-body"><i class="icon-calendar-empty"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

@ -177,7 +177,7 @@
.ical-url {
input {
cursor : text !important;
input, input[readonly] {
cursor : text;
}
}

Loading…
Cancel
Save