update recording saving

This commit is contained in:
Luke Pulverenti
2016-05-04 16:50:47 -04:00
parent 68ae463381
commit 33c002684e
7 changed files with 404 additions and 282 deletions

View File

@@ -1,54 +0,0 @@
using MediaBrowser.Controller;
using System;
using System.IO;
using System.Linq;
using CommonIO;
namespace MediaBrowser.Api.Library
{
/// <summary>
/// Class LibraryHelpers
/// </summary>
public static class LibraryHelpers
{
/// <summary>
/// The shortcut file extension
/// </summary>
private const string ShortcutFileExtension = ".mblink";
/// <summary>
/// The shortcut file search
/// </summary>
private const string ShortcutFileSearch = "*" + ShortcutFileExtension;
/// <summary>
/// Deletes a shortcut from within a virtual folder, within either the default view or a user view
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <param name="virtualFolderName">Name of the virtual folder.</param>
/// <param name="mediaPath">The media path.</param>
/// <param name="appPaths">The app paths.</param>
/// <exception cref="System.IO.DirectoryNotFoundException">The media folder does not exist</exception>
public static void RemoveMediaPath(IFileSystem fileSystem, string virtualFolderName, string mediaPath, IServerApplicationPaths appPaths)
{
if (string.IsNullOrWhiteSpace(mediaPath))
{
throw new ArgumentNullException("mediaPath");
}
var rootFolderPath = appPaths.DefaultUserViewsPath;
var path = Path.Combine(rootFolderPath, virtualFolderName);
if (!fileSystem.DirectoryExists(path))
{
throw new DirectoryNotFoundException(string.Format("The media collection {0} does not exist", virtualFolderName));
}
var shortcut = Directory.EnumerateFiles(path, ShortcutFileSearch, SearchOption.AllDirectories).FirstOrDefault(f => fileSystem.ResolveShortcut(f).Equals(mediaPath, StringComparison.OrdinalIgnoreCase));
if (!string.IsNullOrEmpty(shortcut))
{
fileSystem.DeleteFile(shortcut);
}
}
}
}

View File

@@ -268,46 +268,7 @@ namespace MediaBrowser.Api.Library
/// <param name="request">The request.</param>
public void Delete(RemoveVirtualFolder request)
{
if (string.IsNullOrWhiteSpace(request.Name))
{
throw new ArgumentNullException("request");
}
var rootFolderPath = _appPaths.DefaultUserViewsPath;
var path = Path.Combine(rootFolderPath, request.Name);
if (!_fileSystem.DirectoryExists(path))
{
throw new DirectoryNotFoundException("The media folder does not exist");
}
_libraryMonitor.Stop();
try
{
_fileSystem.DeleteDirectory(path, true);
}
finally
{
Task.Run(() =>
{
// No need to start if scanning the library because it will handle it
if (request.RefreshLibrary)
{
_libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None);
}
else
{
// Need to add a delay here or directory watchers may still pick up the changes
var task = Task.Delay(1000);
// Have to block here to allow exceptions to bubble
Task.WaitAll(task);
_libraryMonitor.Start();
}
});
}
_libraryManager.RemoveVirtualFolder(request.Name, request.RefreshLibrary);
}
/// <summary>
@@ -364,7 +325,7 @@ namespace MediaBrowser.Api.Library
try
{
LibraryHelpers.RemoveMediaPath(_fileSystem, request.Name, request.Path, _appPaths);
_libraryManager.RemoveMediaPath(request.Name, request.Path);
}
finally
{

View File

@@ -129,7 +129,6 @@
<Compile Include="ItemUpdateService.cs" />
<Compile Include="Library\LibraryService.cs" />
<Compile Include="Library\FileOrganizationService.cs" />
<Compile Include="Library\LibraryHelpers.cs" />
<Compile Include="Library\LibraryStructureService.cs" />
<Compile Include="LiveTv\LiveTvService.cs" />
<Compile Include="LocalizationService.cs" />