Fraser commited on
Commit
dd3fe0a
Β·
1 Parent(s): 2fffdb4
src/lib/components/AutoTrainerScanner/AutoTrainerScanner.svelte CHANGED
@@ -159,8 +159,20 @@
159
 
160
  async function onTrainerImageCompleted(imagePath: string, picletId: number) {
161
  console.log(`βœ… Trainer image completed: ${imagePath} -> Piclet ID: ${picletId}`);
162
- await markImageProcessingCompleted(imagePath, picletId);
 
 
 
 
 
 
 
 
163
  await updateProgress();
 
 
 
 
164
  }
165
 
166
  async function onTrainerImageFailed(imagePath: string, error: string) {
 
159
 
160
  async function onTrainerImageCompleted(imagePath: string, picletId: number) {
161
  console.log(`βœ… Trainer image completed: ${imagePath} -> Piclet ID: ${picletId}`);
162
+ console.log(`πŸ”§ DEBUG: Marking ${imagePath} as completed in database...`);
163
+
164
+ try {
165
+ await markImageProcessingCompleted(imagePath, picletId);
166
+ console.log(`βœ… DEBUG: Successfully marked ${imagePath} as completed`);
167
+ } catch (error) {
168
+ console.error(`❌ DEBUG: Failed to mark ${imagePath} as completed:`, error);
169
+ }
170
+
171
  await updateProgress();
172
+
173
+ // Check what getNextPendingImage returns after this update
174
+ const nextImage = await getNextPendingImage();
175
+ console.log(`πŸ”§ DEBUG: Next pending image after completion:`, nextImage?.imagePath || 'null');
176
  }
177
 
178
  async function onTrainerImageFailed(imagePath: string, error: string) {
src/lib/db/trainerScanning.ts CHANGED
@@ -116,11 +116,19 @@ export async function markImageProcessingCompleted(
116
  imagePath: string,
117
  picletInstanceId: number
118
  ): Promise<void> {
119
- await updateScanProgress(imagePath, {
120
- status: 'completed',
121
- picletInstanceId,
122
- completedAt: new Date()
123
- });
 
 
 
 
 
 
 
 
124
  }
125
 
126
  // Mark image processing as failed
 
116
  imagePath: string,
117
  picletInstanceId: number
118
  ): Promise<void> {
119
+ console.log(`πŸ”§ DB DEBUG: markImageProcessingCompleted called for: ${imagePath}`);
120
+
121
+ try {
122
+ await updateScanProgress(imagePath, {
123
+ status: 'completed',
124
+ picletInstanceId,
125
+ completedAt: new Date()
126
+ });
127
+ console.log(`βœ… DB DEBUG: Successfully updated ${imagePath} to completed status`);
128
+ } catch (error) {
129
+ console.error(`❌ DB DEBUG: Failed to update ${imagePath}:`, error);
130
+ throw error;
131
+ }
132
  }
133
 
134
  // Mark image processing as failed