dashcam 1.0.1-beta.28 → 1.0.1-beta.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/dashcam.js CHANGED
@@ -466,43 +466,58 @@ program
466
466
 
467
467
  console.log('Recording stopped successfully');
468
468
 
469
- // Check if the result already has a shareLink (from signal handler upload)
470
- if (result.shareLink) {
471
- console.log('📹 Watch your recording:', result.shareLink);
469
+ // Wait for upload to complete (background process handles this)
470
+ logger.debug('Waiting for background upload to complete...');
471
+ console.log(' Uploading recording...');
472
+
473
+ // Wait up to 2 minutes for upload result to appear
474
+ const maxWaitForUpload = 120000; // 2 minutes
475
+ const startWaitForUpload = Date.now();
476
+ let uploadResult = null;
477
+
478
+ while (!uploadResult && (Date.now() - startWaitForUpload) < maxWaitForUpload) {
479
+ uploadResult = processManager.readUploadResult();
480
+ if (!uploadResult) {
481
+ await new Promise(resolve => setTimeout(resolve, 1000)); // Check every second
482
+ }
483
+ }
484
+
485
+ logger.debug('Upload result read attempt', { found: !!uploadResult, shareLink: uploadResult?.shareLink });
486
+
487
+ if (uploadResult && uploadResult.shareLink) {
488
+ console.log('📹 Watch your recording:', uploadResult.shareLink);
489
+ // Clean up the result file now that we've read it
472
490
  processManager.cleanup();
473
491
  process.exit(0);
474
492
  }
475
493
 
476
- // Otherwise, check if upload result file was written
477
- const uploadResultFromFile = processManager.readUploadResult();
478
- logger.debug('Upload result read attempt', { found: !!uploadResultFromFile, shareLink: uploadResultFromFile?.shareLink });
494
+ // Check if files still exist - if not, background process already uploaded
495
+ const filesExist = fs.existsSync(result.outputPath) &&
496
+ (!result.gifPath || fs.existsSync(result.gifPath)) &&
497
+ (!result.snapshotPath || fs.existsSync(result.snapshotPath));
479
498
 
480
- if (uploadResultFromFile && uploadResultFromFile.shareLink) {
481
- console.log('📹 Watch your recording:', uploadResultFromFile.shareLink);
482
- processManager.cleanup();
499
+ if (!filesExist) {
500
+ console.log(' Recording uploaded by background process');
501
+ logger.info('Files were cleaned up by background process');
483
502
  process.exit(0);
484
503
  }
485
504
 
486
- // No upload result found - need to upload ourselves
487
- // This commonly happens on Windows where signal handlers work differently
488
- logger.info('No upload result found, uploading now...');
505
+ // Always attempt to upload - let upload function find project if needed
489
506
  console.log('Uploading recording...');
490
-
491
507
  try {
492
508
  const uploadResult = await upload(result.outputPath, {
493
509
  title: activeStatus?.options?.title,
494
510
  description: activeStatus?.options?.description,
495
- project: activeStatus?.options?.project,
511
+ project: activeStatus?.options?.project, // May be undefined, that's ok
496
512
  duration: result.duration,
497
513
  clientStartDate: result.clientStartDate,
498
514
  apps: result.apps,
499
- logs: result.logs,
515
+ icons: result.icons,
500
516
  gifPath: result.gifPath,
501
517
  snapshotPath: result.snapshotPath
502
518
  });
503
519
 
504
520
  console.log('📹 Watch your recording:', uploadResult.shareLink);
505
- processManager.cleanup();
506
521
  } catch (uploadError) {
507
522
  console.error('Upload failed:', uploadError.message);
508
523
  console.log('Recording saved locally:', result.outputPath);
@@ -171,14 +171,9 @@ class ProcessManager {
171
171
  this.cleanup({ preserveResult: true });
172
172
  return result;
173
173
  } else {
174
- // Different process - send signal to stop it
174
+ // Different process - send signal (for backward compatibility if needed)
175
175
  logger.info('Stopping active recording process', { pid });
176
-
177
- try {
178
- process.kill(pid, 'SIGINT');
179
- } catch (error) {
180
- logger.warn('Failed to send SIGINT, process may have already exited', { error: error.message });
181
- }
176
+ process.kill(pid, 'SIGINT');
182
177
 
183
178
  // Wait for the process to actually finish
184
179
  const maxWaitTime = 120000; // 2 minutes max
@@ -190,55 +185,12 @@ class ProcessManager {
190
185
 
191
186
  if (this.isProcessRunning(pid)) {
192
187
  logger.warn('Process did not stop within timeout, forcing termination');
193
- try {
194
- process.kill(pid, 'SIGKILL');
195
- } catch (error) {
196
- logger.warn('Failed to send SIGKILL', { error: error.message });
197
- }
188
+ process.kill(pid, 'SIGKILL');
198
189
  await new Promise(resolve => setTimeout(resolve, 1000));
199
190
  }
200
191
 
201
- // Wait a bit for upload result file to be written by the signal handler
202
- logger.debug('Waiting for upload result file...');
203
- const maxWaitForUpload = 10000; // 10 seconds
204
- const startWaitForUpload = Date.now();
205
- let uploadResult = null;
206
-
207
- while (!uploadResult && (Date.now() - startWaitForUpload) < maxWaitForUpload) {
208
- uploadResult = this.readUploadResult();
209
- if (!uploadResult) {
210
- await new Promise(resolve => setTimeout(resolve, 500));
211
- }
212
- }
213
-
214
- // If upload result exists, the signal handler did the upload
215
- if (uploadResult) {
216
- logger.info('Upload completed by recording process');
217
- if (status) {
218
- const basePath = status.outputPath.substring(0, status.outputPath.lastIndexOf('.'));
219
- const result = {
220
- outputPath: status.outputPath,
221
- gifPath: `${basePath}.gif`,
222
- snapshotPath: `${basePath}.png`,
223
- duration: Date.now() - status.startTime,
224
- clientStartDate: status.startTime,
225
- apps: [],
226
- logs: [],
227
- shareLink: uploadResult.shareLink,
228
- replayId: uploadResult.replayId
229
- };
230
-
231
- this.cleanup({ preserveResult: false }); // Clean up everything including result
232
- return result;
233
- }
234
- }
235
-
236
- // If no upload result, we need to handle it ourselves
237
- // This can happen on Windows where signal handlers don't work the same way
238
- logger.warn('No upload result found, handling upload in stop command');
239
-
240
192
  if (status) {
241
- logger.info('Reconstructing result from status', {
193
+ logger.info('Recording stopped, returning status', {
242
194
  outputPath: status.outputPath,
243
195
  duration: Date.now() - status.startTime
244
196
  });
@@ -254,14 +206,7 @@ class ProcessManager {
254
206
  logs: []
255
207
  };
256
208
 
257
- // Don't cleanup yet - let the stop command handle upload
258
- // Just update status to not recording
259
- this.writeStatus({
260
- isRecording: false,
261
- completedTime: Date.now(),
262
- pid: status.pid
263
- });
264
-
209
+ this.cleanup({ preserveResult: true });
265
210
  return result;
266
211
  } else {
267
212
  throw new Error('No status information available for active recording');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dashcam",
3
- "version": "1.0.1-beta.28",
3
+ "version": "1.0.1-beta.29",
4
4
  "description": "Minimal CLI version of Dashcam desktop app",
5
5
  "main": "bin/index.js",
6
6
  "bin": {