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

@@ -2640,7 +2640,52 @@ namespace MediaBrowser.Server.Implementations.Library
}
}
public void RemoveVirtualFolder(string name, bool refreshLibrary)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException("name");
}
var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
var path = Path.Combine(rootFolderPath, name);
if (!_fileSystem.DirectoryExists(path))
{
throw new DirectoryNotFoundException("The media folder does not exist");
}
_libraryMonitorFactory().Stop();
try
{
_fileSystem.DeleteDirectory(path, true);
}
finally
{
Task.Run(() =>
{
// No need to start if scanning the library because it will handle it
if (refreshLibrary)
{
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);
_libraryMonitorFactory().Start();
}
});
}
}
private const string ShortcutFileExtension = ".mblink";
private const string ShortcutFileSearch = "*" + ShortcutFileExtension;
public void AddMediaPath(string virtualFolderName, string path)
{
if (string.IsNullOrWhiteSpace(path))
@@ -2668,5 +2713,28 @@ namespace MediaBrowser.Server.Implementations.Library
_fileSystem.CreateShortcut(lnk, path);
}
public void RemoveMediaPath(string virtualFolderName, string mediaPath)
{
if (string.IsNullOrWhiteSpace(mediaPath))
{
throw new ArgumentNullException("mediaPath");
}
var rootFolderPath = ConfigurationManager.ApplicationPaths.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);
}
}
}
}