Wrap downloader in a catch

This commit is contained in:
Cameron Redmore 2025-04-26 12:07:42 +01:00
parent c1cff132b3
commit ef002ec79b

View file

@ -16,7 +16,10 @@ export async function getMantisSettings()
if (!MANTIS_API_ENDPOINT || !MANTIS_API_KEY)
{
throw new Error('Mantis API endpoint or key not configured in environment variables.');
return {
url: null,
headers: null,
};
}
const headers = {
Authorization: `${MANTIS_API_KEY}`,
@ -210,28 +213,35 @@ const downloadQueue = [];
export async function setup()
{
// Initialize the download queue
downloadQueue.length = 0;
// Start the process of checking for new tickets
processNewMantisTickets();
setInterval(processNewMantisTickets, 5 * 60 * 1000); // Check for new tickets every 5 minutes
setInterval(processTicketsInQueue, 1 * 1000); // Process the queue every 10 seconds
if(process.env.LOAD_ALL_MANTISES == 'true')
try
{
for (let i = 3000; i <= 5100; i++)
{
//Check if the ticket already exists in the database
const existingTicket = await prisma.mantisIssue.findUnique({
where: { id: i },
select: { updatedAt: true } // Only select needed field
});
// Initialize the download queue
downloadQueue.length = 0;
if (!existingTicket)
// Start the process of checking for new tickets
processNewMantisTickets();
setInterval(processNewMantisTickets, 5 * 60 * 1000); // Check for new tickets every 5 minutes
setInterval(processTicketsInQueue, 1 * 1000); // Process the queue every 10 seconds
if(process.env.LOAD_ALL_MANTISES == 'true')
{
for (let i = 3000; i <= 5100; i++)
{
downloadQueue.push(i);
//Check if the ticket already exists in the database
const existingTicket = await prisma.mantisIssue.findUnique({
where: { id: i },
select: { updatedAt: true } // Only select needed field
});
if (!existingTicket)
{
downloadQueue.push(i);
}
}
}
}
catch(error)
{
logger.error('Error setting up Mantis downloader:', error);
}
}