diff --git a/src/Tgstation.Server.Api/Models/Instance.cs b/src/Tgstation.Server.Api/Models/Instance.cs
index 73e772ea7b..474016bacb 100644
--- a/src/Tgstation.Server.Api/Models/Instance.cs
+++ b/src/Tgstation.Server.Api/Models/Instance.cs
@@ -28,6 +28,7 @@ namespace Tgstation.Server.Api.Models
///
/// If the is online
///
+ [Required]
public bool? Online { get; set; }
///
@@ -37,9 +38,10 @@ namespace Tgstation.Server.Api.Models
public ConfigurationType? ConfigurationType { get; set; }
///
- /// The time interval in minutes the repository is automatically pulled and compiles
+ /// The time interval in minutes the repository is automatically pulled and compiles. 0 disables
///
- public int? AutoUpdateInterval { get; set; }
+ [Required]
+ public uint? AutoUpdateInterval { get; set; }
///
/// The representing a change of
@@ -54,7 +56,8 @@ namespace Tgstation.Server.Api.Models
Name = Name,
Path = Path,
Online = Online,
- ConfigurationType = ConfigurationType
+ ConfigurationType = ConfigurationType,
+ AutoUpdateInterval = AutoUpdateInterval
};
}
}
diff --git a/src/Tgstation.Server.Host/Components/IInstance.cs b/src/Tgstation.Server.Host/Components/IInstance.cs
index 58b1014f2c..8e5b2edf80 100644
--- a/src/Tgstation.Server.Host/Components/IInstance.cs
+++ b/src/Tgstation.Server.Host/Components/IInstance.cs
@@ -74,6 +74,6 @@ namespace Tgstation.Server.Host.Components
///
/// The new auto update inteval
/// A representing the running operation
- Task SetAutoUpdateInterval(int? newInterval);
+ Task SetAutoUpdateInterval(uint newInterval);
}
}
\ No newline at end of file
diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs
index 45693457a6..080c469aab 100644
--- a/src/Tgstation.Server.Host/Components/Instance.cs
+++ b/src/Tgstation.Server.Host/Components/Instance.cs
@@ -113,12 +113,12 @@ namespace Tgstation.Server.Host.Components
/// How many minutes the operation should repeat. Does not include running time
/// The for the operation
/// A representing the running operation
- async Task TimerLoop(int minutes, CancellationToken cancellationToken)
+ async Task TimerLoop(uint minutes, CancellationToken cancellationToken)
{
while (true)
try
{
- await Task.Delay(new TimeSpan(0, minutes, 0), cancellationToken).ConfigureAwait(false);
+ await Task.Delay(new TimeSpan(0, minutes > Int32.MaxValue ? Int32.MaxValue : (int)minutes, 0), cancellationToken).ConfigureAwait(false);
try
{
@@ -229,7 +229,7 @@ namespace Tgstation.Server.Host.Components
///
public async Task StartAsync(CancellationToken cancellationToken)
{
- await Task.WhenAll(SetAutoUpdateInterval(metadata.AutoUpdateInterval), Configuration.StartAsync(cancellationToken), ByondManager.StartAsync(cancellationToken), Chat.StartAsync(cancellationToken), CompileJobConsumer.StartAsync(cancellationToken)).ConfigureAwait(false);
+ await Task.WhenAll(SetAutoUpdateInterval(metadata.AutoUpdateInterval.Value), Configuration.StartAsync(cancellationToken), ByondManager.StartAsync(cancellationToken), Chat.StartAsync(cancellationToken), CompileJobConsumer.StartAsync(cancellationToken)).ConfigureAwait(false);
//dependent on so many things, its just safer this way
await Watchdog.StartAsync(cancellationToken).ConfigureAwait(false);
@@ -243,10 +243,10 @@ namespace Tgstation.Server.Host.Components
}
///
- public Task StopAsync(CancellationToken cancellationToken) => Task.WhenAll(SetAutoUpdateInterval(null), Configuration.StopAsync(cancellationToken), ByondManager.StopAsync(cancellationToken), Watchdog.StopAsync(cancellationToken), Chat.StopAsync(cancellationToken), CompileJobConsumer.StopAsync(cancellationToken));
+ public Task StopAsync(CancellationToken cancellationToken) => Task.WhenAll(SetAutoUpdateInterval(0), Configuration.StopAsync(cancellationToken), ByondManager.StopAsync(cancellationToken), Watchdog.StopAsync(cancellationToken), Chat.StopAsync(cancellationToken), CompileJobConsumer.StopAsync(cancellationToken));
///
- public async Task SetAutoUpdateInterval(int? newInterval)
+ public async Task SetAutoUpdateInterval(uint newInterval)
{
Task toWait;
lock (this)
@@ -260,7 +260,7 @@ namespace Tgstation.Server.Host.Components
toWait = Task.CompletedTask;
}
await toWait.ConfigureAwait(false);
- if (!newInterval.HasValue)
+ if (newInterval == 0)
return;
lock (this)
{
@@ -269,7 +269,7 @@ namespace Tgstation.Server.Host.Components
return;
timerCts?.Dispose();
timerCts = new CancellationTokenSource();
- timerTask = TimerLoop(newInterval.Value, timerCts.Token);
+ timerTask = TimerLoop(newInterval, timerCts.Token);
}
}
diff --git a/src/Tgstation.Server.Host/Controllers/InstanceController.cs b/src/Tgstation.Server.Host/Controllers/InstanceController.cs
index af4e9807ec..fb07995f22 100644
--- a/src/Tgstation.Server.Host/Controllers/InstanceController.cs
+++ b/src/Tgstation.Server.Host/Controllers/InstanceController.cs
@@ -139,6 +139,7 @@ namespace Tgstation.Server.Host.Controllers
Name = model.Name,
Online = false,
Path = model.Path,
+ AutoUpdateInterval = model.AutoUpdateInterval ?? 0,
RepositorySettings = new RepositorySettings
{
CommitterEmail = "tgstation-server@users.noreply.github.com",