added realtime monitor setting

This commit is contained in:
Luke Pulverenti 2014-01-29 15:30:26 -05:00
parent eced7ed068
commit 2353dc1aee
3 changed files with 27 additions and 4 deletions

View File

@ -227,6 +227,8 @@ namespace MediaBrowser.Model.Configuration
public TvFileOrganizationOptions TvFileOrganizationOptions { get; set; } public TvFileOrganizationOptions TvFileOrganizationOptions { get; set; }
public LiveTvOptions LiveTvOptions { get; set; } public LiveTvOptions LiveTvOptions { get; set; }
public bool EnableRealtimeMonitor { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class. /// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
/// </summary> /// </summary>
@ -294,6 +296,8 @@ namespace MediaBrowser.Model.Configuration
LiveTvOptions = new LiveTvOptions(); LiveTvOptions = new LiveTvOptions();
TvFileOrganizationOptions = new TvFileOrganizationOptions(); TvFileOrganizationOptions = new TvFileOrganizationOptions();
EnableRealtimeMonitor = true;
} }
} }

View File

@ -79,9 +79,15 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
foreach (var path in watchLocations) foreach (var path in watchLocations)
{ {
if (options.LeftOverFileExtensionsToDelete.Length > 0) var deleteExtensions = options.LeftOverFileExtensionsToDelete
.Select(i => i.Trim().TrimStart('.'))
.Where(i => !string.IsNullOrEmpty(i))
.Select(i => "." + i)
.ToList();
if (deleteExtensions.Count > 0)
{ {
DeleteLeftOverFiles(path, options.LeftOverFileExtensionsToDelete); DeleteLeftOverFiles(path, deleteExtensions);
} }
if (options.DeleteEmptyFolders) if (options.DeleteEmptyFolders)

View File

@ -129,15 +129,28 @@ namespace MediaBrowser.Server.Implementations.IO
/// <param name="sender">The source of the event.</param> /// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="PowerModeChangedEventArgs"/> instance containing the event data.</param> /// <param name="e">The <see cref="PowerModeChangedEventArgs"/> instance containing the event data.</param>
void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e) void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
Restart();
}
private void Restart()
{ {
Stop(); Stop();
Start(); Start();
} }
public void Start()
{
if (ConfigurationManager.Configuration.EnableRealtimeMonitor)
{
StartInternal();
}
}
/// <summary> /// <summary>
/// Starts this instance. /// Starts this instance.
/// </summary> /// </summary>
public void Start() private void StartInternal()
{ {
LibraryManager.ItemAdded += LibraryManager_ItemAdded; LibraryManager.ItemAdded += LibraryManager_ItemAdded;
LibraryManager.ItemRemoved += LibraryManager_ItemRemoved; LibraryManager.ItemRemoved += LibraryManager_ItemRemoved;
@ -359,7 +372,7 @@ namespace MediaBrowser.Server.Implementations.IO
{ {
throw new ArgumentNullException("path"); throw new ArgumentNullException("path");
} }
var filename = Path.GetFileName(path); var filename = Path.GetFileName(path);
// Ignore certain files // Ignore certain files