diff --git a/src/Tgstation.Server.Api/Models/Job.cs b/src/Tgstation.Server.Api/Models/Job.cs
index bbb375ca00..3ac1549daa 100644
--- a/src/Tgstation.Server.Api/Models/Job.cs
+++ b/src/Tgstation.Server.Api/Models/Job.cs
@@ -17,12 +17,6 @@
[Permissions(DenyWrite = true)]
public User CancelledBy { get; set; }
- ///
- /// The the job belongs to
- ///
- [Permissions(DenyWrite = true)]
- public Instance Instance { get; set; }
-
///
/// Optional progress between 0 and 100 inclusive
///
diff --git a/src/Tgstation.Server.Client/Components/IJobsClient.cs b/src/Tgstation.Server.Client/Components/IJobsClient.cs
index b35b200462..151dcfc33e 100644
--- a/src/Tgstation.Server.Client/Components/IJobsClient.cs
+++ b/src/Tgstation.Server.Client/Components/IJobsClient.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Tgstation.Server.Api.Models;
@@ -32,5 +33,15 @@ namespace Tgstation.Server.Client.Components
/// The for the operation
/// A representing the running operation
Task Cancel(Job job, CancellationToken cancellationToken);
- }
+
+ ///
+ /// Creates a that completes when a given is completed
+ ///
+ /// The to create a for
+ /// The rate in to poll the server for results
+ /// A to run with 0-100 progress
+ /// The which will trigger the cancellation of the
+ /// A resulting in a complete
+ Task CreateTaskFromJob(Job job, TimeSpan requeryRate, Action progressCallback, CancellationToken cancellationToken);
+ }
}
diff --git a/src/Tgstation.Server.Client/Components/JobsClient.cs b/src/Tgstation.Server.Client/Components/JobsClient.cs
index 283a36a35d..359be4887b 100644
--- a/src/Tgstation.Server.Client/Components/JobsClient.cs
+++ b/src/Tgstation.Server.Client/Components/JobsClient.cs
@@ -38,5 +38,26 @@ namespace Tgstation.Server.Client.Components
///
public Task Read(Job job, CancellationToken cancellationToken) => apiClient.Read(Routes.SetID(Routes.Jobs, job.Id), instance.Id, cancellationToken);
+
+ ///
+ public async Task CreateTaskFromJob(Job job, TimeSpan requeryRate, Action progressCallback, CancellationToken cancellationToken)
+ {
+ if (job == null)
+ throw new ArgumentNullException(nameof(job));
+
+ int? lastProgress = null;
+ while (!job.StoppedAt.HasValue)
+ {
+ await Task.Delay(requeryRate, cancellationToken).ConfigureAwait(false);
+ job = await Read(job, cancellationToken).ConfigureAwait(false);
+ if(job.Progress.HasValue && job.Progress != lastProgress)
+ {
+ progressCallback(job.Progress.Value);
+ lastProgress = job.Progress;
+ }
+ }
+ return job;
+ }
+
}
}
\ No newline at end of file
diff --git a/src/Tgstation.Server.Client/IServerClient.cs b/src/Tgstation.Server.Client/IServerClient.cs
index 5766b102a0..3fa1d13666 100644
--- a/src/Tgstation.Server.Client/IServerClient.cs
+++ b/src/Tgstation.Server.Client/IServerClient.cs
@@ -39,14 +39,5 @@ namespace Tgstation.Server.Client
/// The of the
///
Task Version(CancellationToken cancellationToken);
-
- ///
- /// Creates a that completes when a given is completed
- ///
- /// The to create a for
- /// The rate in to poll the server for results
- /// The which will trigger the cancellation of the
- /// A resulting in a complete
- Task CreateTaskFromJob(Job job, TimeSpan requeryRate, CancellationToken cancellationToken);
}
}
diff --git a/src/Tgstation.Server.Client/ServerClient.cs b/src/Tgstation.Server.Client/ServerClient.cs
index 51b1e971ad..a592c3630d 100644
--- a/src/Tgstation.Server.Client/ServerClient.cs
+++ b/src/Tgstation.Server.Client/ServerClient.cs
@@ -53,23 +53,6 @@ namespace Tgstation.Server.Client
///
public void Dispose() => apiClient.Dispose();
-
- ///
- public async Task CreateTaskFromJob(Job job, TimeSpan requeryRate, CancellationToken cancellationToken)
- {
- if (job == null)
- throw new ArgumentNullException(nameof(job));
-
- var jobsClient = Instances.CreateClient(job.Instance).Jobs;
-
- while (!job.StoppedAt.HasValue)
- {
- await Task.Delay(requeryRate, cancellationToken).ConfigureAwait(false);
- job = await jobsClient.Read(job, cancellationToken).ConfigureAwait(false);
- }
- return job;
- }
-
///
public Task Version(CancellationToken cancellationToken) => apiClient.Read(Routes.Root, cancellationToken);
}
diff --git a/src/Tgstation.Server.Host/Models/Job.cs b/src/Tgstation.Server.Host/Models/Job.cs
index 4e9529dc81..0b56cca428 100644
--- a/src/Tgstation.Server.Host/Models/Job.cs
+++ b/src/Tgstation.Server.Host/Models/Job.cs
@@ -34,8 +34,7 @@ namespace Tgstation.Server.Host.Models
CancelRightsType = CancelRightsType,
Description = Description,
ExceptionDetails = ExceptionDetails,
- StartedBy = StartedBy.ToApi(),
- Instance = Instance.ToApi()
+ StartedBy = StartedBy.ToApi()
};
}
}