Merge pull request #1444 from MediaBrowser/dev

Dev
pull/702/head
Luke 9 years ago
commit 6f2d87a0f9

@ -569,7 +569,7 @@ namespace MediaBrowser.Api.Library
{ {
throw new ArgumentException("This command cannot be used for remote or virtual items."); throw new ArgumentException("This command cannot be used for remote or virtual items.");
} }
if (_fileSystem.DirectoryExists(item.Path)) if (_fileSystem.DirectoryExists(item.Path))
{ {
throw new ArgumentException("This command cannot be used for directories."); throw new ArgumentException("This command cannot be used for directories.");
} }
@ -789,12 +789,10 @@ namespace MediaBrowser.Api.Library
return Task.FromResult(true); return Task.FromResult(true);
} }
if (item is ILiveTvRecording) return item.Delete(new DeleteOptions
{ {
return _liveTv.DeleteRecording(i); DeleteFileLocation = true
} });
return _libraryManager.DeleteItem(item);
}).ToArray(); }).ToArray();
Task.WaitAll(tasks); Task.WaitAll(tasks);

@ -1980,5 +1980,10 @@ namespace MediaBrowser.Controller.Entities
{ {
return new[] { Id }; return new[] { Id };
} }
public virtual Task Delete(DeleteOptions options)
{
return LibraryManager.DeleteItem(this, options);
}
} }
} }

@ -6,14 +6,6 @@ namespace MediaBrowser.Controller.Library
{ {
public static class LibraryManagerExtensions public static class LibraryManagerExtensions
{ {
public static Task DeleteItem(this ILibraryManager manager, BaseItem item)
{
return manager.DeleteItem(item, new DeleteOptions
{
DeleteFileLocation = true
});
}
public static BaseItem GetItemById(this ILibraryManager manager, string id) public static BaseItem GetItemById(this ILibraryManager manager, string id)
{ {
return manager.GetItemById(new Guid(id)); return manager.GetItemById(new Guid(id));

@ -44,6 +44,13 @@ namespace MediaBrowser.Controller.LiveTv
/// <returns>Task.</returns> /// <returns>Task.</returns>
Task DeleteRecording(string id); Task DeleteRecording(string id);
/// <summary>
/// Deletes the recording.
/// </summary>
/// <param name="recording">The recording.</param>
/// <returns>Task.</returns>
Task DeleteRecording(ILiveTvRecording recording);
/// <summary> /// <summary>
/// Cancels the timer. /// Cancels the timer.
/// </summary> /// </summary>

@ -9,6 +9,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Threading.Tasks;
using MediaBrowser.Controller.Library;
namespace MediaBrowser.Controller.LiveTv namespace MediaBrowser.Controller.LiveTv
{ {
@ -144,5 +146,10 @@ namespace MediaBrowser.Controller.LiveTv
{ {
return IsVisible(user); return IsVisible(user);
} }
public override Task Delete(DeleteOptions options)
{
return LiveTvManager.DeleteRecording(this);
}
} }
} }

@ -9,6 +9,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Threading.Tasks;
using MediaBrowser.Controller.Library;
namespace MediaBrowser.Controller.LiveTv namespace MediaBrowser.Controller.LiveTv
{ {
@ -159,5 +161,10 @@ namespace MediaBrowser.Controller.LiveTv
{ {
return IsVisible(user); return IsVisible(user);
} }
public override Task Delete(DeleteOptions options)
{
return LiveTvManager.DeleteRecording(this);
}
} }
} }

@ -114,7 +114,7 @@ namespace MediaBrowser.Dlna.PlayTo
{ {
Url = url, Url = url,
UserAgent = USERAGENT, UserAgent = USERAGENT,
LogRequest = logRequest || _config.GetDlnaConfiguration().EnableDebugLogging, LogRequest = logRequest || _config.GetDlnaConfiguration().EnableDebugLog,
LogErrorResponseBody = true LogErrorResponseBody = true
}; };

@ -27,7 +27,7 @@ namespace MediaBrowser.Dlna.Service
{ {
try try
{ {
var enableDebugLogging = Config.GetDlnaConfiguration().EnableDebugLogging; var enableDebugLogging = Config.GetDlnaConfiguration().EnableDebugLog;
if (enableDebugLogging) if (enableDebugLogging)
{ {

@ -217,7 +217,7 @@ namespace MediaBrowser.Dlna.Ssdp
return; return;
} }
if (_config.GetDlnaConfiguration().EnableDebugLogging) if (_config.GetDlnaConfiguration().EnableDebugLog)
{ {
var headerTexts = args.Headers.Select(i => string.Format("{0}={1}", i.Key, i.Value)); var headerTexts = args.Headers.Select(i => string.Format("{0}={1}", i.Key, i.Value));
var headerText = string.Join(",", headerTexts.ToArray()); var headerText = string.Join(",", headerTexts.ToArray());

@ -92,7 +92,7 @@ namespace MediaBrowser.Dlna.Ssdp
{ {
TimeSpan delay = GetSearchDelay(headers); TimeSpan delay = GetSearchDelay(headers);
if (_config.GetDlnaConfiguration().EnableDebugLogging) if (_config.GetDlnaConfiguration().EnableDebugLog)
{ {
_logger.Debug("Delaying search response by {0} seconds", delay.TotalSeconds); _logger.Debug("Delaying search response by {0} seconds", delay.TotalSeconds);
} }
@ -163,7 +163,7 @@ namespace MediaBrowser.Dlna.Ssdp
{ {
var msg = new SsdpMessageBuilder().BuildMessage(header, values); var msg = new SsdpMessageBuilder().BuildMessage(header, values);
var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLogging; var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLog;
for (var i = 0; i < sendCount; i++) for (var i = 0; i < sendCount; i++)
{ {
@ -202,7 +202,7 @@ namespace MediaBrowser.Dlna.Ssdp
private void RespondToSearch(EndPoint endpoint, string deviceType) private void RespondToSearch(EndPoint endpoint, string deviceType)
{ {
var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLogging; var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLog;
var isLogged = false; var isLogged = false;
@ -305,7 +305,7 @@ namespace MediaBrowser.Dlna.Ssdp
var received = (byte[])result.AsyncState; var received = (byte[])result.AsyncState;
var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLogging; var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLog;
if (enableDebugLogging) if (enableDebugLogging)
{ {
@ -404,7 +404,7 @@ namespace MediaBrowser.Dlna.Ssdp
private void NotifyAll() private void NotifyAll()
{ {
var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLogging; var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLog;
if (enableDebugLogging) if (enableDebugLogging)
{ {

@ -5,7 +5,7 @@ namespace MediaBrowser.Model.Configuration
{ {
public bool EnablePlayTo { get; set; } public bool EnablePlayTo { get; set; }
public bool EnableServer { get; set; } public bool EnableServer { get; set; }
public bool EnableDebugLogging { get; set; } public bool EnableDebugLog { get; set; }
public bool BlastAliveMessages { get; set; } public bool BlastAliveMessages { get; set; }
public int ClientDiscoveryIntervalSeconds { get; set; } public int ClientDiscoveryIntervalSeconds { get; set; }
public int BlastAliveMessageIntervalSeconds { get; set; } public int BlastAliveMessageIntervalSeconds { get; set; }

@ -175,7 +175,11 @@ namespace MediaBrowser.Providers.TV
{ {
_logger.Info("Removing virtual season {0} {1}", seasonToRemove.Series.Name, seasonToRemove.IndexNumber); _logger.Info("Removing virtual season {0} {1}", seasonToRemove.Series.Name, seasonToRemove.IndexNumber);
await _libraryManager.DeleteItem(seasonToRemove).ConfigureAwait(false); await seasonToRemove.Delete(new DeleteOptions
{
DeleteFileLocation = true
}).ConfigureAwait(false);
hasChanges = true; hasChanges = true;
} }

@ -315,7 +315,11 @@ namespace MediaBrowser.Providers.TV
{ {
_logger.Info("Removing missing/unaired episode {0} {1}x{2}", episodeToRemove.Series.Name, episodeToRemove.ParentIndexNumber, episodeToRemove.IndexNumber); _logger.Info("Removing missing/unaired episode {0} {1}x{2}", episodeToRemove.Series.Name, episodeToRemove.ParentIndexNumber, episodeToRemove.IndexNumber);
await _libraryManager.DeleteItem(episodeToRemove).ConfigureAwait(false); await episodeToRemove.Delete(new DeleteOptions
{
DeleteFileLocation = true
}).ConfigureAwait(false);
hasChanges = true; hasChanges = true;
} }
@ -380,7 +384,11 @@ namespace MediaBrowser.Providers.TV
{ {
_logger.Info("Removing virtual season {0} {1}", seasonToRemove.Series.Name, seasonToRemove.IndexNumber); _logger.Info("Removing virtual season {0} {1}", seasonToRemove.Series.Name, seasonToRemove.IndexNumber);
await _libraryManager.DeleteItem(seasonToRemove).ConfigureAwait(false); await seasonToRemove.Delete(new DeleteOptions
{
DeleteFileLocation = true
}).ConfigureAwait(false);
hasChanges = true; hasChanges = true;
} }

@ -1673,6 +1673,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
throw new ResourceNotFoundException(string.Format("Recording with Id {0} not found", recordingId)); throw new ResourceNotFoundException(string.Format("Recording with Id {0} not found", recordingId));
} }
await DeleteRecording(recording).ConfigureAwait(false);
}
public async Task DeleteRecording(ILiveTvRecording recording)
{
var service = GetService(recording.ServiceName); var service = GetService(recording.ServiceName);
try try
@ -1685,7 +1690,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
} }
_lastRecordingRefreshTime = DateTime.MinValue; _lastRecordingRefreshTime = DateTime.MinValue;
// This is the responsibility of the live tv service // This is the responsibility of the live tv service
await _libraryManager.DeleteItem((BaseItem)recording, new DeleteOptions await _libraryManager.DeleteItem((BaseItem)recording, new DeleteOptions
{ {

@ -205,10 +205,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
{ {
_logger.Info("Cleaning item {0} type: {1} path: {2}", item.Name, item.GetType().Name, item.Path ?? string.Empty); _logger.Info("Cleaning item {0} type: {1} path: {2}", item.Name, item.GetType().Name, item.Path ?? string.Empty);
await _libraryManager.DeleteItem(item, new DeleteOptions await item.Delete(new DeleteOptions
{ {
DeleteFileLocation = false DeleteFileLocation = false
});
}).ConfigureAwait(false);
} }
numComplete++; numComplete++;
@ -274,10 +275,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
_logger.Info("Deleting item from database {0} because path no longer exists. type: {1} path: {2}", libraryItem.Name, libraryItem.GetType().Name, libraryItem.Path ?? string.Empty); _logger.Info("Deleting item from database {0} because path no longer exists. type: {1} path: {2}", libraryItem.Name, libraryItem.GetType().Name, libraryItem.Path ?? string.Empty);
await _libraryManager.DeleteItem(libraryItem, new DeleteOptions await libraryItem.Delete(new DeleteOptions
{ {
DeleteFileLocation = false DeleteFileLocation = false
});
}).ConfigureAwait(false);
} }
catch (OperationCanceledException) catch (OperationCanceledException)
{ {

Loading…
Cancel
Save