|
@@ -54,15 +54,12 @@ export class WatcherService {
|
|
|
this.lastOptions = conservativeOptions;
|
|
this.lastOptions = conservativeOptions;
|
|
|
this.watcher
|
|
this.watcher
|
|
|
.on('add', (file: string) => {
|
|
.on('add', (file: string) => {
|
|
|
- this.logger.log(`File added: ${file}`);
|
|
|
|
|
this.handleFileAdded(file);
|
|
this.handleFileAdded(file);
|
|
|
})
|
|
})
|
|
|
.on('change', (file: string) => {
|
|
.on('change', (file: string) => {
|
|
|
- this.logger.log(`File changed: ${file}`);
|
|
|
|
|
this.eventsGateway.emitFileUpdate({ type: 'change', file });
|
|
this.eventsGateway.emitFileUpdate({ type: 'change', file });
|
|
|
})
|
|
})
|
|
|
.on('unlink', (file: string) => {
|
|
.on('unlink', (file: string) => {
|
|
|
- this.logger.log(`File removed: ${file}`);
|
|
|
|
|
this.eventsGateway.emitFileUpdate({ type: 'unlink', file });
|
|
this.eventsGateway.emitFileUpdate({ type: 'unlink', file });
|
|
|
})
|
|
})
|
|
|
.on('error', (error: Error) => {
|
|
.on('error', (error: Error) => {
|
|
@@ -72,7 +69,6 @@ export class WatcherService {
|
|
|
error: error.message,
|
|
error: error.message,
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
- this.logger.log('Watcher started.');
|
|
|
|
|
this.eventsGateway.emitWatcherUpdate({
|
|
this.eventsGateway.emitWatcherUpdate({
|
|
|
type: 'started',
|
|
type: 'started',
|
|
|
watches: enabledWatches,
|
|
watches: enabledWatches,
|
|
@@ -90,7 +86,6 @@ export class WatcherService {
|
|
|
|
|
|
|
|
// Check if this is a video file (basic extension check)
|
|
// Check if this is a video file (basic extension check)
|
|
|
if (!this.isVideoFile(file)) {
|
|
if (!this.isVideoFile(file)) {
|
|
|
- this.logger.log(`Skipping non-video file: ${file}`);
|
|
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -105,9 +100,6 @@ export class WatcherService {
|
|
|
const datasetSettings = datasetConfig[dataset];
|
|
const datasetSettings = datasetConfig[dataset];
|
|
|
|
|
|
|
|
if (!datasetSettings || !datasetSettings.enabled) {
|
|
if (!datasetSettings || !datasetSettings.enabled) {
|
|
|
- this.logger.log(
|
|
|
|
|
- `Dataset ${dataset} is not enabled, skipping file: ${file}`,
|
|
|
|
|
- );
|
|
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -251,7 +243,6 @@ export class WatcherService {
|
|
|
if (!fs.existsSync(outputDir)) {
|
|
if (!fs.existsSync(outputDir)) {
|
|
|
try {
|
|
try {
|
|
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
|
- this.logger.log(`Created output directory: ${outputDir}`);
|
|
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
this.logger.error(
|
|
this.logger.error(
|
|
|
`Failed to create output directory ${outputDir}: ${error.message}`,
|
|
`Failed to create output directory ${outputDir}: ${error.message}`,
|
|
@@ -289,9 +280,6 @@ export class WatcherService {
|
|
|
const outputExists = fs.existsSync(output);
|
|
const outputExists = fs.existsSync(output);
|
|
|
|
|
|
|
|
if (outputExists) {
|
|
if (outputExists) {
|
|
|
- this.logger.log(
|
|
|
|
|
- `Output file already exists, skipping automatic task creation: ${output}`,
|
|
|
|
|
- );
|
|
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -300,19 +288,12 @@ export class WatcherService {
|
|
|
if (existingTask) {
|
|
if (existingTask) {
|
|
|
// If task exists and is currently processing, reset to pending for retry
|
|
// If task exists and is currently processing, reset to pending for retry
|
|
|
if (existingTask.status === 'processing') {
|
|
if (existingTask.status === 'processing') {
|
|
|
- this.logger.log(
|
|
|
|
|
- `Resetting stuck processing task ${existingTask.id} to pending for file: ${file}`,
|
|
|
|
|
- );
|
|
|
|
|
this.taskQueue.updateTaskStatus(existingTask.id, 'pending');
|
|
this.taskQueue.updateTaskStatus(existingTask.id, 'pending');
|
|
|
this.eventsGateway.emitTaskUpdate({
|
|
this.eventsGateway.emitTaskUpdate({
|
|
|
type: 'reset',
|
|
type: 'reset',
|
|
|
taskId: existingTask.id,
|
|
taskId: existingTask.id,
|
|
|
file,
|
|
file,
|
|
|
});
|
|
});
|
|
|
- } else {
|
|
|
|
|
- this.logger.log(
|
|
|
|
|
- `Task already exists for file: ${file} (status: ${existingTask.status})`,
|
|
|
|
|
- );
|
|
|
|
|
}
|
|
}
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -327,14 +308,6 @@ export class WatcherService {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// Update file record to indicate processing has started
|
|
// Update file record to indicate processing has started
|
|
|
- this.db.setFile(dataset, file, {
|
|
|
|
|
- status: 'pending',
|
|
|
|
|
- date: new Date().toISOString(),
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- this.logger.log(`Created task ${task.id} for file: ${file}`);
|
|
|
|
|
-
|
|
|
|
|
- // Emit file update event
|
|
|
|
|
this.eventsGateway.emitFileUpdate({
|
|
this.eventsGateway.emitFileUpdate({
|
|
|
type: 'add',
|
|
type: 'add',
|
|
|
file,
|
|
file,
|
|
@@ -443,11 +416,9 @@ export class WatcherService {
|
|
|
if (this.watcher && this.isWatching) {
|
|
if (this.watcher && this.isWatching) {
|
|
|
await this.watcher.close();
|
|
await this.watcher.close();
|
|
|
this.isWatching = false;
|
|
this.isWatching = false;
|
|
|
- this.logger.log('Watcher stopped.');
|
|
|
|
|
this.eventsGateway.emitWatcherUpdate({ type: 'stopped' });
|
|
this.eventsGateway.emitWatcherUpdate({ type: 'stopped' });
|
|
|
return { stopped: true };
|
|
return { stopped: true };
|
|
|
}
|
|
}
|
|
|
- this.logger.warn('Watcher is not running.');
|
|
|
|
|
return { stopped: false, message: 'Watcher is not running.' };
|
|
return { stopped: false, message: 'Watcher is not running.' };
|
|
|
}
|
|
}
|
|
|
|
|
|