/// <summary> /// Deletes the specified request. /// </summary> /// <param name="request">The request.</param> public void Delete(RemoveMediaPath request) { if (string.IsNullOrWhiteSpace(request.Name)) { throw new ArgumentNullException(nameof(request)); } _libraryMonitor.Stop(); try { _libraryManager.RemoveMediaPath(request.Name, request.Path); } finally { Task.Run(() => { // No need to start if scanning the library because it will handle it if (request.RefreshLibrary) { _libraryManager.ValidateMediaLibrary(new SimpleProgress <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(); } }); } }
/// <summary> /// Deletes the specified request. /// </summary> /// <param name="request">The request.</param> public async void Delete(RemoveMediaPath request) { _directoryWatchers.Stop(); try { if (string.IsNullOrEmpty(request.UserId)) { LibraryHelpers.RemoveMediaPath(request.Name, request.Path, null, _appPaths); } else { var user = _userManager.GetUserById(new Guid(request.UserId)); LibraryHelpers.RemoveMediaPath(request.Name, request.Path, user, _appPaths); } // Need to add a delay here or directory watchers may still pick up the changes await Task.Delay(1000).ConfigureAwait(false); } finally { _directoryWatchers.Start(); } if (request.RefreshLibrary) { _libraryManager.ValidateMediaLibrary(new Progress <double>(), CancellationToken.None); } }
/// <summary> /// Deletes the specified request. /// </summary> /// <param name="request">The request.</param> public void Delete(RemoveMediaPath request) { _directoryWatchers.Stop(); try { if (string.IsNullOrEmpty(request.UserId)) { LibraryHelpers.RemoveMediaPath(_fileSystem, request.Name, request.Path, null, _appPaths); } else { var user = _userManager.GetUserById(new Guid(request.UserId)); LibraryHelpers.RemoveMediaPath(_fileSystem, request.Name, request.Path, user, _appPaths); } // 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); } finally { _directoryWatchers.Start(); } if (request.RefreshLibrary) { _libraryManager.ValidateMediaLibrary(new Progress <double>(), CancellationToken.None); } }
/// <summary> /// Deletes the specified request. /// </summary> /// <param name="request">The request.</param> public void Delete(RemoveMediaPath request) { if (string.IsNullOrEmpty(request.UserId)) { LibraryHelpers.RemoveMediaPath(request.Name, request.Path, null, _appPaths); } else { var user = _userManager.GetUserById(new Guid(request.UserId)); LibraryHelpers.RemoveMediaPath(request.Name, request.Path, user, _appPaths); } }
/// <summary> /// Deletes the specified request. /// </summary> /// <param name="request">The request.</param> public void Delete(RemoveMediaPath request) { if (string.IsNullOrEmpty(request.UserId)) { LibraryHelpers.RemoveMediaPath(request.Name, request.Path, null, _appPaths); } else { var user = _userManager.GetUserById(new Guid(request.UserId)); LibraryHelpers.RemoveMediaPath(request.Name, request.Path, user, _appPaths); } _libraryManager.ValidateMediaLibrary(new Progress <double>(), CancellationToken.None); }