dashcam 1.3.16-beta → 1.3.18-beta

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.
@@ -11,11 +11,33 @@ import fs from 'fs';
11
11
  import path from 'path';
12
12
  import os from 'os';
13
13
 
14
- // Get process directory for status files (system temp for cross-session access)
15
- const PROCESS_DIR = path.join(os.tmpdir(), 'dashcam-cli');
14
+ // Use a consistent location across all contexts
15
+ // Windows: C:\ProgramData\dashcam-cli (shared across all users/sessions)
16
+ // Others: /tmp/dashcam-cli (standard temp location)
17
+ const getProcessDir = () => {
18
+ if (process.platform === 'win32') {
19
+ // Use PROGRAMDATA which is consistent across all contexts on Windows
20
+ const programData = process.env.PROGRAMDATA || 'C:\\ProgramData';
21
+ return path.join(programData, 'dashcam-cli');
22
+ } else {
23
+ // Use /tmp directly on Unix-like systems for consistency
24
+ return '/tmp/dashcam-cli';
25
+ }
26
+ };
27
+
28
+ const PROCESS_DIR = getProcessDir();
16
29
  const STATUS_FILE = path.join(PROCESS_DIR, 'status.json');
17
30
  const RESULT_FILE = path.join(PROCESS_DIR, 'upload-result.json');
18
31
 
32
+ console.log('[Background INIT] Process directory:', PROCESS_DIR);
33
+ console.log('[Background INIT] Status file:', STATUS_FILE);
34
+
35
+ // Ensure directory exists
36
+ if (!fs.existsSync(PROCESS_DIR)) {
37
+ console.log('[Background INIT] Creating process directory');
38
+ fs.mkdirSync(PROCESS_DIR, { recursive: true });
39
+ }
40
+
19
41
  // Parse options from command line argument
20
42
  const optionsJson = process.argv[2];
21
43
  if (!optionsJson) {
package/bin/dashcam.js CHANGED
@@ -399,7 +399,9 @@ program
399
399
  platform: process.platform,
400
400
  cwd: process.cwd(),
401
401
  pid: process.pid,
402
- processDir: require('path').join(require('os').tmpdir(), 'dashcam-cli')
402
+ processDir: process.platform === 'win32'
403
+ ? require('path').join(process.env.PROGRAMDATA || 'C:\\ProgramData', 'dashcam-cli')
404
+ : '/tmp/dashcam-cli'
403
405
  });
404
406
 
405
407
  const isActive = processManager.isRecordingActive();
@@ -407,15 +409,19 @@ program
407
409
 
408
410
  if (!isActive) {
409
411
  console.log('No active recording to stop');
412
+
413
+ const statusPath = process.platform === 'win32'
414
+ ? require('path').join(process.env.PROGRAMDATA || 'C:\\ProgramData', 'dashcam-cli', 'status.json')
415
+ : '/tmp/dashcam-cli/status.json';
416
+
410
417
  logger.warn('Stop command called but no active recording found', {
411
418
  platform: process.platform,
412
- statusFile: require('path').join(require('os').tmpdir(), 'dashcam-cli', 'status.json'),
413
- statusFileExists: require('fs').existsSync(require('path').join(require('os').tmpdir(), 'dashcam-cli', 'status.json'))
419
+ statusFile: statusPath,
420
+ statusFileExists: require('fs').existsSync(statusPath)
414
421
  });
415
422
 
416
423
  // Try to read and display status file for debugging
417
424
  try {
418
- const statusPath = require('path').join(require('os').tmpdir(), 'dashcam-cli', 'status.json');
419
425
  if (require('fs').existsSync(statusPath)) {
420
426
  const statusContent = require('fs').readFileSync(statusPath, 'utf8');
421
427
  logger.debug('Status file contents', { content: statusContent });
@@ -8,14 +8,35 @@ import { logger } from './logger.js';
8
8
  const __filename = fileURLToPath(import.meta.url);
9
9
  const __dirname = path.dirname(__filename);
10
10
 
11
- // Use system temp directory for cross-session communication
12
- const PROCESS_DIR = path.join(os.tmpdir(), 'dashcam-cli');
11
+ // Use a consistent location across all contexts
12
+ // Windows: C:\ProgramData\dashcam-cli (shared across all users/sessions)
13
+ // Others: /tmp/dashcam-cli (standard temp location)
14
+ const getProcessDir = () => {
15
+ if (process.platform === 'win32') {
16
+ // Use PROGRAMDATA which is consistent across all contexts on Windows
17
+ const programData = process.env.PROGRAMDATA || 'C:\\ProgramData';
18
+ return path.join(programData, 'dashcam-cli');
19
+ } else {
20
+ // Use /tmp directly on Unix-like systems for consistency
21
+ return '/tmp/dashcam-cli';
22
+ }
23
+ };
24
+
25
+ const PROCESS_DIR = getProcessDir();
13
26
  const STATUS_FILE = path.join(PROCESS_DIR, 'status.json');
14
27
  const RESULT_FILE = path.join(PROCESS_DIR, 'upload-result.json');
15
28
 
29
+ console.log('[INIT] Process Manager initialized');
30
+ console.log('[INIT] Process directory:', PROCESS_DIR);
31
+ console.log('[INIT] Status file:', STATUS_FILE);
32
+ console.log('[INIT] Platform:', process.platform);
33
+
16
34
  // Ensure process directory exists
17
35
  if (!fs.existsSync(PROCESS_DIR)) {
36
+ console.log('[INIT] Creating process directory:', PROCESS_DIR);
18
37
  fs.mkdirSync(PROCESS_DIR, { recursive: true });
38
+ } else {
39
+ console.log('[INIT] Process directory exists:', PROCESS_DIR);
19
40
  }
20
41
 
21
42
  class ProcessManager {
@@ -161,6 +182,10 @@ class ProcessManager {
161
182
  }
162
183
 
163
184
  isRecordingActive() {
185
+ console.log('[DEBUG] Checking if recording is active...');
186
+ console.log('[DEBUG] Status file path:', STATUS_FILE);
187
+ console.log('[DEBUG] Status file exists:', fs.existsSync(STATUS_FILE));
188
+
164
189
  logger.debug('Checking if recording is active...', {
165
190
  statusFile: STATUS_FILE,
166
191
  processDir: PROCESS_DIR,
@@ -169,6 +194,8 @@ class ProcessManager {
169
194
 
170
195
  const status = this.readStatus();
171
196
 
197
+ console.log('[DEBUG] Status read result:', status);
198
+
172
199
  logger.debug('Status check result', {
173
200
  hasStatus: !!status,
174
201
  hasPid: !!(status && status.pid),
@@ -178,23 +205,27 @@ class ProcessManager {
178
205
  });
179
206
 
180
207
  if (!status) {
208
+ console.log('[DEBUG] No status found - recording not active');
181
209
  logger.debug('No status found - recording not active');
182
210
  return false;
183
211
  }
184
212
 
185
213
  if (!status.pid) {
214
+ console.log('[DEBUG] Status has no PID - marking as completed');
186
215
  logger.debug('Status has no PID - marking as completed');
187
216
  this.markStatusCompleted({ reason: 'no_pid_in_status' });
188
217
  return false;
189
218
  }
190
219
 
191
220
  const processRunning = this.isProcessRunning(status.pid);
221
+ console.log('[DEBUG] Process running check:', { pid: status.pid, isRunning: processRunning });
192
222
  logger.debug('Process running check', {
193
223
  pid: status.pid,
194
224
  isRunning: processRunning
195
225
  });
196
226
 
197
227
  if (!processRunning) {
228
+ console.log('[DEBUG] Process not running - marking as completed:', { pid: status.pid });
198
229
  logger.debug('Process not running - marking as completed', {
199
230
  pid: status.pid,
200
231
  wasRecording: status.isRecording
@@ -207,6 +238,7 @@ class ProcessManager {
207
238
  return false;
208
239
  }
209
240
 
241
+ console.log('[DEBUG] Recording active status:', { isRecording: status.isRecording, pid: status.pid });
210
242
  logger.debug('Recording active status', {
211
243
  isRecording: status.isRecording,
212
244
  pid: status.pid
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dashcam",
3
- "version": "1.3.16-beta",
3
+ "version": "1.3.18-beta",
4
4
  "description": "Minimal CLI version of Dashcam desktop app",
5
5
  "main": "bin/dashcam.js",
6
6
  "bin": {