Skip to content

Commit 8d8a51b

Browse files
committed
refactor: Only queue stuff if it's not already queued.
1 parent 10a34e6 commit 8d8a51b

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CFLookup/Jobs/StoreCFApiFiles.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ public class StoreCFApiFiles
1717

1818
public async static Task RunAsync(PerformContext context, IJobCancellationToken token)
1919
{
20+
if (SharedMethods.CheckIfTaskIsScheduledOrInProgress("StoreCFApiProjects", "RunAsync"))
21+
{
22+
return;
23+
}
24+
2025
using (var scope = Program.ServiceProvider.CreateScope())
2126
{
2227
try

CFLookup/Jobs/StoreCFApiProjects.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ public class StoreCFApiProjects
1717

1818
public async static Task RunAsync(PerformContext context, IJobCancellationToken token)
1919
{
20+
if (SharedMethods.CheckIfTaskIsScheduledOrInProgress("StoreCFApiFiles", "RunAsync"))
21+
{
22+
return;
23+
}
24+
2025
using (var scope = Program.ServiceProvider.CreateScope())
2126
{
2227
try

CFLookup/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ private static async Task Main(string[] args)
191191
RecurringJob.AddOrUpdate("cflookup:SaveMinecraftModStats", () => SaveMinecraftModStats.RunAsync(null), Cron.Hourly());
192192
RecurringJob.AddOrUpdate("cflookup:CacheMCStatsOvertime", () => CacheMCOverTime.RunAsync(null), "*/30 * * * *");
193193

194-
if (!SharedMethods.CheckIfTaskIsScheduledOrInProgress("StoreCFApiProjects", "RunAsync"))
194+
if (!SharedMethods.CheckIfTaskIsScheduledOrInProgress("StoreCFApiProjects", "RunAsync") &&
195+
!SharedMethods.CheckIfTaskIsScheduledOrInProgress("StoreCFApiFiles", "RunAsync"))
195196
{
196197
BackgroundJob.Schedule(() => StoreCFApiProjects.RunAsync(null, JobCancellationToken.Null), TimeSpan.FromSeconds(10));
197198
}

0 commit comments

Comments
 (0)