mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-03 19:17:24 -05:00 
			
		
		
		
	add message for db upgrade
This commit is contained in:
		
							parent
							
								
									4d7c016224
								
							
						
					
					
						commit
						96120099cb
					
				@ -268,13 +268,18 @@ namespace MediaBrowser.Server.Implementations.HttpServer
 | 
			
		||||
 | 
			
		||||
        private bool EnableLogging(string url)
 | 
			
		||||
        {
 | 
			
		||||
            var parts = url.Split(new[] { '?' }, 2);
 | 
			
		||||
 | 
			
		||||
            var extension = Path.GetExtension(parts[0]);
 | 
			
		||||
            var extension = GetExtension(url);
 | 
			
		||||
 | 
			
		||||
            return string.IsNullOrWhiteSpace(extension) || !_skipLogExtensions.ContainsKey(extension);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private string GetExtension(string url)
 | 
			
		||||
        {
 | 
			
		||||
            var parts = url.Split(new[] { '?' }, 2);
 | 
			
		||||
 | 
			
		||||
            return Path.GetExtension(parts[0]);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Overridable method that can be used to implement a custom hnandler
 | 
			
		||||
        /// </summary>
 | 
			
		||||
@ -339,6 +344,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer
 | 
			
		||||
            {
 | 
			
		||||
                httpRes.Write(GlobalResponse);
 | 
			
		||||
                httpRes.ContentType = "text/plain";
 | 
			
		||||
 | 
			
		||||
                if (!string.Equals(GetExtension(urlString), "html", StringComparison.OrdinalIgnoreCase))
 | 
			
		||||
                {
 | 
			
		||||
                    httpRes.StatusCode = 503;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                return Task.FromResult(true);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -174,5 +174,6 @@
 | 
			
		||||
    "HeaderWriter": "Writers",
 | 
			
		||||
    "HeaderParentalRatings": "Parental Ratings",
 | 
			
		||||
    "HeaderCommunityRatings": "Community ratings",
 | 
			
		||||
    "StartupEmbyServerIsLoading": "Emby Server is loading. Please try again shortly."
 | 
			
		||||
    "StartupEmbyServerIsLoading": "Emby Server is loading. Please try again shortly.",
 | 
			
		||||
    "DbUpgradeMessage":  "Please wait while your Emby Server database is upgraded. {0}% complete."
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -173,5 +173,6 @@
 | 
			
		||||
    "HeaderWriter": "Writers",
 | 
			
		||||
    "HeaderParentalRatings": "Parental Ratings",
 | 
			
		||||
    "HeaderCommunityRatings": "Community ratings",
 | 
			
		||||
    "StartupEmbyServerIsLoading": "Emby Server is loading. Please try again shortly."
 | 
			
		||||
    "StartupEmbyServerIsLoading": "Emby Server is loading. Please try again shortly.",
 | 
			
		||||
    "DbUpgradeMessage":  "Please wait while your Emby Server database is upgraded. {0}% complete."
 | 
			
		||||
}
 | 
			
		||||
@ -9,11 +9,14 @@ using MediaBrowser.Model.Entities;
 | 
			
		||||
using MediaBrowser.Model.Logging;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using CommonIO;
 | 
			
		||||
using MediaBrowser.Controller.Channels;
 | 
			
		||||
using MediaBrowser.Controller.Entities.Audio;
 | 
			
		||||
using MediaBrowser.Controller.Localization;
 | 
			
		||||
using MediaBrowser.Controller.Net;
 | 
			
		||||
 | 
			
		||||
namespace MediaBrowser.Server.Implementations.Persistence
 | 
			
		||||
{
 | 
			
		||||
@ -24,16 +27,21 @@ namespace MediaBrowser.Server.Implementations.Persistence
 | 
			
		||||
        private readonly ILogger _logger;
 | 
			
		||||
        private readonly IServerConfigurationManager _config;
 | 
			
		||||
        private readonly IFileSystem _fileSystem;
 | 
			
		||||
        private readonly IHttpServer _httpServer;
 | 
			
		||||
        private readonly ILocalizationManager _localization;
 | 
			
		||||
 | 
			
		||||
        public const int MigrationVersion = 7;
 | 
			
		||||
        public const int MigrationVersion = 12;
 | 
			
		||||
        public static bool EnableUnavailableMessage = false;
 | 
			
		||||
 | 
			
		||||
        public CleanDatabaseScheduledTask(ILibraryManager libraryManager, IItemRepository itemRepo, ILogger logger, IServerConfigurationManager config, IFileSystem fileSystem)
 | 
			
		||||
        public CleanDatabaseScheduledTask(ILibraryManager libraryManager, IItemRepository itemRepo, ILogger logger, IServerConfigurationManager config, IFileSystem fileSystem, IHttpServer httpServer, ILocalizationManager localization)
 | 
			
		||||
        {
 | 
			
		||||
            _libraryManager = libraryManager;
 | 
			
		||||
            _itemRepo = itemRepo;
 | 
			
		||||
            _logger = logger;
 | 
			
		||||
            _config = config;
 | 
			
		||||
            _fileSystem = fileSystem;
 | 
			
		||||
            _httpServer = httpServer;
 | 
			
		||||
            _localization = localization;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public string Name
 | 
			
		||||
@ -54,7 +62,23 @@ namespace MediaBrowser.Server.Implementations.Persistence
 | 
			
		||||
        public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
 | 
			
		||||
        {
 | 
			
		||||
            var innerProgress = new ActionableProgress<double>();
 | 
			
		||||
            innerProgress.RegisterAction(p => progress.Report(.4 * p));
 | 
			
		||||
            innerProgress.RegisterAction(p =>
 | 
			
		||||
            {
 | 
			
		||||
                double newPercentCommplete = .4 * p;
 | 
			
		||||
                if (EnableUnavailableMessage)
 | 
			
		||||
                {
 | 
			
		||||
                    var html = "<!doctype html><html><head><title>Emby</title></head><body>";
 | 
			
		||||
                    var text = _localization.GetLocalizedString("DbUpgradeMessage");
 | 
			
		||||
                    html += string.Format(text, newPercentCommplete.ToString("N2", CultureInfo.InvariantCulture));
 | 
			
		||||
 | 
			
		||||
                    html += "<script>setTimeout(function(){window.location.reload(true);}, 5000);</script>";
 | 
			
		||||
                    html += "</body></html>";
 | 
			
		||||
 | 
			
		||||
                    _httpServer.GlobalResponse = html;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                progress.Report(newPercentCommplete);
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            await UpdateToLatestSchema(cancellationToken, innerProgress).ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
@ -69,6 +93,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
 | 
			
		||||
            progress.Report(100);
 | 
			
		||||
 | 
			
		||||
            await _itemRepo.UpdateInheritedValues(cancellationToken).ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
            if (EnableUnavailableMessage)
 | 
			
		||||
            {
 | 
			
		||||
                EnableUnavailableMessage = false;
 | 
			
		||||
                _httpServer.GlobalResponse = null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private async Task UpdateToLatestSchema(CancellationToken cancellationToken, IProgress<double> progress)
 | 
			
		||||
 | 
			
		||||
@ -82,7 +82,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
 | 
			
		||||
 | 
			
		||||
        private IDbCommand _updateInheritedRatingCommand;
 | 
			
		||||
        
 | 
			
		||||
        private const int LatestSchemaVersion = 40;
 | 
			
		||||
        private const int LatestSchemaVersion = 44;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
 | 
			
		||||
 | 
			
		||||
@ -20,9 +20,11 @@ namespace MediaBrowser.Server.Startup.Common.Migrations
 | 
			
		||||
        {
 | 
			
		||||
            if (_config.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion)
 | 
			
		||||
            {
 | 
			
		||||
                CleanDatabaseScheduledTask.EnableUnavailableMessage = true;
 | 
			
		||||
                
 | 
			
		||||
                Task.Run(async () =>
 | 
			
		||||
                {
 | 
			
		||||
                    await Task.Delay(2000).ConfigureAwait(false);
 | 
			
		||||
                    await Task.Delay(1000).ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
                    _taskManager.QueueScheduledTask<CleanDatabaseScheduledTask>();
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user