dashcam 1.3.17-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.
- package/bin/dashcam-background.js +24 -2
- package/bin/dashcam.js +10 -4
- package/lib/processManager.js +23 -2
- package/package.json +1 -1
|
@@ -11,11 +11,33 @@ import fs from 'fs';
|
|
|
11
11
|
import path from 'path';
|
|
12
12
|
import os from 'os';
|
|
13
13
|
|
|
14
|
-
//
|
|
15
|
-
|
|
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:
|
|
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:
|
|
413
|
-
statusFileExists: require('fs').existsSync(
|
|
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 });
|
package/lib/processManager.js
CHANGED
|
@@ -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
|
|
12
|
-
|
|
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 {
|