Merge branch 'bugfix/DownloadQueue_stops_working' into develop
* bugfix/DownloadQueue_stops_working: Fixed an error which caused null pointer exceptions in discord framework and interrupted the scanning queue permanently Changed message count to acutally count scanned messages even if they already have scanned before Contine on exception during scanning New Build
This commit is contained in:
commit
0f1b6f8f9b
|
@ -74,7 +74,8 @@ namespace DML.AppCore.Classes
|
||||||
var channel = FindChannelById(guild, ChannelId);
|
var channel = FindChannelById(guild, ChannelId);
|
||||||
|
|
||||||
Debug("Checking channel access");
|
Debug("Checking channel access");
|
||||||
if (!channel.Users.Contains(channel.Guild.CurrentUser))
|
//channel.GetUser(channel.Guild.CurrentUser.Id);
|
||||||
|
if (channel.GetUser(channel.Guild.CurrentUser.Id) == null)
|
||||||
{
|
{
|
||||||
Info("Skipping channel without access");
|
Info("Skipping channel without access");
|
||||||
return result;
|
return result;
|
||||||
|
@ -126,6 +127,8 @@ namespace DML.AppCore.Classes
|
||||||
if (!IsValid)
|
if (!IsValid)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
Core.Scheduler.MessagesScanned++;
|
||||||
|
|
||||||
Debug($"Processing message {m.Id}");
|
Debug($"Processing message {m.Id}");
|
||||||
if (m.Id < lastId)
|
if (m.Id < lastId)
|
||||||
{
|
{
|
||||||
|
@ -148,8 +151,6 @@ namespace DML.AppCore.Classes
|
||||||
Trace($"Added message {m.Id}");
|
Trace($"Added message {m.Id}");
|
||||||
}
|
}
|
||||||
Debug($"Finished message {m.Id}");
|
Debug($"Finished message {m.Id}");
|
||||||
|
|
||||||
Core.Scheduler.MessagesScanned++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finished = finished || messages.Count < limit;
|
finished = finished || messages.Count < limit;
|
||||||
|
|
|
@ -91,73 +91,81 @@ namespace DML.AppCore.Classes
|
||||||
Logger.Info("Started JobScheduler...");
|
Logger.Info("Started JobScheduler...");
|
||||||
while (Run)
|
while (Run)
|
||||||
{
|
{
|
||||||
Logger.Debug("Entering job list handler loop...");
|
try
|
||||||
//foreach (var job in JobList)
|
|
||||||
for (var i = JobList.Count - 1; i >= 0; i--)
|
|
||||||
{
|
{
|
||||||
var job = JobList[i];
|
Logger.Debug("Entering job list handler loop...");
|
||||||
Logger.Debug($"Checking job {job}");
|
//foreach (var job in JobList)
|
||||||
var hasJob = false;
|
for (var i = JobList.Count - 1; i >= 0; i--)
|
||||||
|
|
||||||
Logger.Trace("Locking scheduler...");
|
|
||||||
lock (this)
|
|
||||||
{
|
{
|
||||||
Logger.Trace("Checking if job is already performed...");
|
var job = JobList[i];
|
||||||
hasJob = RunningJobs.ContainsKey(job.Id);
|
Logger.Debug($"Checking job {job}");
|
||||||
}
|
var hasJob = false;
|
||||||
Logger.Trace("Unlocked scheduler.");
|
|
||||||
|
|
||||||
if (!hasJob)
|
|
||||||
{
|
|
||||||
Logger.Debug("Job is not performed yet...Performing job...");
|
|
||||||
var queue = new Queue<IMessage>();
|
|
||||||
|
|
||||||
Logger.Trace("Locking scheduler...");
|
Logger.Trace("Locking scheduler...");
|
||||||
lock (this)
|
lock (this)
|
||||||
{
|
{
|
||||||
Logger.Trace("Adding job to running jobs.");
|
Logger.Trace("Checking if job is already performed...");
|
||||||
RunningJobs.Add(job.Id, queue);
|
hasJob = RunningJobs.ContainsKey(job.Id);
|
||||||
}
|
}
|
||||||
Logger.Trace("Unlocked scheduler.");
|
Logger.Trace("Unlocked scheduler.");
|
||||||
|
|
||||||
Logger.Trace("Issuing job message scan...");
|
if (!hasJob)
|
||||||
var messages = await job.Scan();
|
|
||||||
|
|
||||||
if (messages == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Logger.Trace($"Adding {messages.Count} messages to queue...");
|
|
||||||
foreach (var msg in messages)
|
|
||||||
{
|
{
|
||||||
queue.Enqueue(msg);
|
Logger.Debug("Job is not performed yet...Performing job...");
|
||||||
}
|
var queue = new Queue<IMessage>();
|
||||||
Logger.Trace($"Added {queue.Count} messages to queue.");
|
|
||||||
|
|
||||||
if (messages.Count != queue.Count)
|
|
||||||
Logger.Warn("Not all messages have been added into the queue.");
|
|
||||||
|
|
||||||
var startedDownload = false;
|
|
||||||
|
|
||||||
while (!startedDownload)
|
|
||||||
{
|
|
||||||
Logger.Debug("Entering loop to check thread availability");
|
|
||||||
Logger.Trace("Locking scheduler...");
|
Logger.Trace("Locking scheduler...");
|
||||||
lock (this)
|
lock (this)
|
||||||
{
|
{
|
||||||
Logger.Trace($"Checking thread limit. Running: {RunningThreads}, Max: {Core.Settings.ThreadLimit}");
|
Logger.Trace("Adding job to running jobs.");
|
||||||
if (RunningThreads >= Core.Settings.ThreadLimit)
|
RunningJobs.Add(job.Id, queue);
|
||||||
continue;
|
|
||||||
|
|
||||||
RunningThreads++;
|
|
||||||
startedDownload = true;
|
|
||||||
}
|
}
|
||||||
Logger.Trace("Unlocked scheduler.");
|
Logger.Trace("Unlocked scheduler.");
|
||||||
}
|
|
||||||
|
|
||||||
Logger.Trace("Start downloading job async.");
|
Logger.Trace("Issuing job message scan...");
|
||||||
Task.Run(() => WorkQueue(job.Id)); // do not await to work parallel
|
var messages = await job.Scan();
|
||||||
|
|
||||||
|
if (messages == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Logger.Trace($"Adding {messages.Count} messages to queue...");
|
||||||
|
foreach (var msg in messages)
|
||||||
|
{
|
||||||
|
queue.Enqueue(msg);
|
||||||
|
}
|
||||||
|
Logger.Trace($"Added {queue.Count} messages to queue.");
|
||||||
|
|
||||||
|
if (messages.Count != queue.Count)
|
||||||
|
Logger.Warn("Not all messages have been added into the queue.");
|
||||||
|
|
||||||
|
var startedDownload = false;
|
||||||
|
|
||||||
|
while (!startedDownload)
|
||||||
|
{
|
||||||
|
Logger.Debug("Entering loop to check thread availability");
|
||||||
|
Logger.Trace("Locking scheduler...");
|
||||||
|
lock (this)
|
||||||
|
{
|
||||||
|
Logger.Trace(
|
||||||
|
$"Checking thread limit. Running: {RunningThreads}, Max: {Core.Settings.ThreadLimit}");
|
||||||
|
if (RunningThreads >= Core.Settings.ThreadLimit)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
RunningThreads++;
|
||||||
|
startedDownload = true;
|
||||||
|
}
|
||||||
|
Logger.Trace("Unlocked scheduler.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.Trace("Start downloading job async.");
|
||||||
|
Task.Run(() => WorkQueue(job.Id)); // do not await to work parallel
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Error(ex.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.0.1.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
[assembly: AssemblyFileVersion("1.0.1.0")]
|
||||||
|
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.0.1.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
[assembly: AssemblyFileVersion("1.0.1.0")]
|
||||||
|
|
Loading…
Reference in a new issue