Merge branch 'refs/heads/feature/kestrel-avalonia-upgrade' into feature/http-server-modernization

# Conflicts:
#	Duplicati.Library.RestAPI/UpdatePollThread.cs
#	Duplicati/Server/Program.cs
#	Duplicati/Server/webroot/ngax/scripts/services/ServerStatus.js
#	Duplicati/WebserverCore/DuplicatiWebserver.cs
This commit is contained in:
natan
2024-04-22 09:35:53 +02:00
235 changed files with 5945 additions and 5567 deletions
+18 -50
View File
@@ -30,7 +30,6 @@ namespace Duplicati.Server
{
private Thread m_thread;
private volatile bool m_terminated = false;
private volatile bool m_download = false;
private volatile bool m_forceCheck = false;
private readonly object m_lock = new object();
private AutoResetEvent m_waitSignal;
@@ -41,7 +40,7 @@ namespace Duplicati.Server
public UpdatePollerStates ThreadState { get; private set; }
public double DownloadProgess
{
get { return m_downloadProgress ; }
get { return m_downloadProgress; }
private set
{
@@ -66,35 +65,16 @@ namespace Duplicati.Server
public void CheckNow()
{
lock(m_lock)
lock (m_lock)
{
m_forceCheck = true;
m_waitSignal.Set();
}
}
public void InstallUpdate()
{
lock(m_lock)
{
m_forceCheck = true;
m_download = true;
m_waitSignal.Set();
}
}
public void ActivateUpdate()
{
if (Duplicati.Library.AutoUpdater.UpdaterManager.SetRunUpdate())
{
IsUpdateRequested = true;
FIXMEGlobal.ApplicationExitEvent.Set();
}
}
public void Terminate()
{
lock(m_lock)
lock (m_lock)
{
m_terminated = true;
m_waitSignal.Set();
@@ -130,12 +110,12 @@ namespace Duplicati.Server
if (nextCheck < DateTime.UtcNow || m_forceCheck)
{
lock(m_lock)
lock (m_lock)
m_forceCheck = false;
ThreadState = UpdatePollerStates.Checking;
FIXMEGlobal.StatusEventNotifyer.SignalNewEvent();
DateTime started = DateTime.UtcNow;
FIXMEGlobal.DataConnection.ApplicationSettings.LastUpdateCheck = started;
nextCheck = FIXMEGlobal.DataConnection.ApplicationSettings.NextUpdateCheck;
@@ -148,7 +128,7 @@ namespace Duplicati.Server
rt = rt == Duplicati.Library.AutoUpdater.ReleaseType.Unknown ? Duplicati.Library.AutoUpdater.AutoUpdateSettings.DefaultUpdateChannel : rt;
try
{
{
var update = Duplicati.Library.AutoUpdater.UpdaterManager.CheckForUpdate(rt);
if (update != null)
FIXMEGlobal.DataConnection.ApplicationSettings.UpdatedVersion = update;
@@ -166,52 +146,40 @@ namespace Duplicati.Server
var updatertstring = FIXMEGlobal.DataConnection.ApplicationSettings.UpdatedVersion.ReleaseType;
if (string.Equals(updatertstring, "preview", StringComparison.OrdinalIgnoreCase))
updatertstring = Library.AutoUpdater.ReleaseType.Experimental.ToString();
if (!Enum.TryParse<Library.AutoUpdater.ReleaseType>(updatertstring, true, out updatert))
updatert = Duplicati.Library.AutoUpdater.ReleaseType.Nightly;
if (updatert == Duplicati.Library.AutoUpdater.ReleaseType.Unknown)
updatert = Duplicati.Library.AutoUpdater.ReleaseType.Nightly;
if (updatert > rt)
FIXMEGlobal.DataConnection.ApplicationSettings.UpdatedVersion = null;
}
if (FIXMEGlobal.DataConnection.ApplicationSettings.UpdatedVersion != null && Duplicati.Library.AutoUpdater.UpdaterManager.TryParseVersion(FIXMEGlobal.DataConnection.ApplicationSettings.UpdatedVersion.Version) > System.Reflection.Assembly.GetExecutingAssembly().GetName().Version)
var updatedinfo = FIXMEGlobal.DataConnection.ApplicationSettings.UpdatedVersion;
if (updatedinfo != null && Duplicati.Library.AutoUpdater.UpdaterManager.TryParseVersion(updatedinfo.Version) > System.Reflection.Assembly.GetExecutingAssembly().GetName().Version)
{
var package = updatedinfo.FindPackage();
FIXMEGlobal.DataConnection.RegisterNotification(
NotificationType.Information,
"Found update",
FIXMEGlobal.DataConnection.ApplicationSettings.UpdatedVersion.Displayname,
updatedinfo.Displayname,
null,
null,
"update:new",
null,
"NewUpdateFound",
null,
(self, all) => {
(self, all) =>
{
return all.FirstOrDefault(x => x.Action == "update:new") ?? self;
}
);
}
}
if (m_download)
{
lock(m_lock)
m_download = false;
var v = FIXMEGlobal.DataConnection.ApplicationSettings.UpdatedVersion;
if (v != null)
{
ThreadState = UpdatePollerStates.Downloading;
FIXMEGlobal.StatusEventNotifyer.SignalNewEvent();
if (Duplicati.Library.AutoUpdater.UpdaterManager.DownloadAndUnpackUpdate(v, (pg) => { DownloadProgess = pg; }))
FIXMEGlobal.StatusEventNotifyer.SignalNewEvent();
}
}
DownloadProgess = 0;
if (ThreadState != UpdatePollerStates.Waiting)
@@ -225,14 +193,14 @@ namespace Duplicati.Server
// Guard against spin-loop
if (waitTime.TotalSeconds < 5)
waitTime = TimeSpan.FromSeconds(5);
// Guard against year-long waits
// A re-check does not cause an update check
if (waitTime.TotalDays > 1)
waitTime = TimeSpan.FromDays(1);
m_waitSignal.WaitOne(waitTime, true);
}
}
}
}
}