Exemple #1
0
        /// <summary>
        /// Posts the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        public async void Post(AddMediaPath request)
        {
            _directoryWatchers.Stop();

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

                    LibraryHelpers.AddMediaPath(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>
        /// Posts the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        public void Post(AddMediaPath request)
        {
            if (string.IsNullOrWhiteSpace(request.Name))
            {
                throw new ArgumentNullException("request");
            }

            _libraryMonitor.Stop();

            try
            {
                _libraryManager.AddMediaPath(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 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();
                    }
                });
            }
        }
Exemple #3
0
        /// <summary>
        /// Posts the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        public void Post(AddMediaPath request)
        {
            _directoryWatchers.Stop();

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

                    LibraryHelpers.AddMediaPath(_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);
            }
        }
Exemple #4
0
        /// <summary>
        /// Posts the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        public void Post(AddMediaPath request)
        {
            if (string.IsNullOrEmpty(request.UserId))
            {
                LibraryHelpers.AddMediaPath(request.Name, request.Path, null, _appPaths);
            }
            else
            {
                var user = _userManager.GetUserById(new Guid(request.UserId));

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

                LibraryHelpers.AddMediaPath(request.Name, request.Path, user, _appPaths);
            }

            _libraryManager.ValidateMediaLibrary(new Progress <double>(), CancellationToken.None);
        }