Exemplo n.º 1
0
        /// <summary>
        /// Deletes the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        public async void Delete(RemoveVirtualFolder request)
        {
            _directoryWatchers.Stop();

            try
            {
                if (string.IsNullOrEmpty(request.UserId))
                {
                    LibraryHelpers.RemoveVirtualFolder(request.Name, null, _appPaths);
                }
                else
                {
                    var user = _userManager.GetUserById(new Guid(request.UserId));

                    LibraryHelpers.RemoveVirtualFolder(request.Name, 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);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        public void Delete(RemoveVirtualFolder request)
        {
            if (string.IsNullOrEmpty(request.UserId))
            {
                LibraryHelpers.RemoveVirtualFolder(request.Name, null, _appPaths);
            }
            else
            {
                var user = _userManager.GetUserById(new Guid(request.UserId));

                LibraryHelpers.RemoveVirtualFolder(request.Name, user, _appPaths);
            }
        }
        /// <summary>
        /// Deletes the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        public void Delete(RemoveVirtualFolder request)
        {
            if (string.IsNullOrEmpty(request.UserId))
            {
                LibraryHelpers.RemoveVirtualFolder(request.Name, null, _appPaths);
            }
            else
            {
                var user = _userManager.GetUserById(new Guid(request.UserId));

                LibraryHelpers.RemoveVirtualFolder(request.Name, user, _appPaths);
            }

            _libraryManager.ValidateMediaLibrary(new Progress <double>(), CancellationToken.None);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Deletes the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        public void Delete(RemoveVirtualFolder request)
        {
            string rootFolderPath;

            if (string.IsNullOrEmpty(request.UserId))
            {
                rootFolderPath = _appPaths.DefaultUserViewsPath;
            }
            else
            {
                var user = _userManager.GetUserById(new Guid(request.UserId));

                rootFolderPath = user.RootFolderPath;
            }

            var path = Path.Combine(rootFolderPath, request.Name);

            if (!Directory.Exists(path))
            {
                throw new DirectoryNotFoundException("The media folder does not exist");
            }

            _directoryWatchers.Stop();
            _directoryWatchers.TemporarilyIgnore(path);

            try
            {
                Directory.Delete(path, true);

                // Need to add a delay here or directory watchers may still pick up the changes
                var delayTask = Task.Delay(1000);
                // Have to block here to allow exceptions to bubble
                Task.WaitAll(delayTask);
            }
            finally
            {
                _directoryWatchers.Start();
                _directoryWatchers.RemoveTempIgnore(path);
            }

            if (request.RefreshLibrary)
            {
                _libraryManager.ValidateMediaLibrary(new Progress <double>(), CancellationToken.None);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Deletes the specified request.
        /// </summary>
        /// <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 (!Directory.Exists(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();
                    }
                });
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Deletes the specified request.
 /// </summary>
 /// <param name="request">The request.</param>
 public Task Delete(RemoveVirtualFolder request)
 {
     return(_libraryManager.RemoveVirtualFolder(request.Name, request.RefreshLibrary));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Deletes the specified request.
 /// </summary>
 /// <param name="request">The request.</param>
 public void Delete(RemoveVirtualFolder request)
 {
     _libraryManager.RemoveVirtualFolder(request.Name, request.RefreshLibrary);
 }