dashcam 1.3.9-beta → 1.3.12-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.
@@ -12,21 +12,10 @@ import path from 'path';
12
12
  import os from 'os';
13
13
 
14
14
  // Get process directory for status files
15
- // Use a fixed system-wide directory for cross-process communication
16
- // On Windows: C:\ProgramData\dashcam-cli
17
- // On Unix: /tmp/dashcam-cli
18
- const PROCESS_DIR = process.platform === 'win32'
19
- ? path.join('C:', 'ProgramData', 'dashcam-cli')
20
- : path.join('/tmp', 'dashcam-cli');
21
- const PID_FILE = path.join(PROCESS_DIR, 'recording.pid');
15
+ const PROCESS_DIR = path.join(os.homedir(), '.dashcam-cli');
22
16
  const STATUS_FILE = path.join(PROCESS_DIR, 'status.json');
23
17
  const RESULT_FILE = path.join(PROCESS_DIR, 'upload-result.json');
24
18
 
25
- // Ensure process directory exists
26
- if (!fs.existsSync(PROCESS_DIR)) {
27
- fs.mkdirSync(PROCESS_DIR, { recursive: true });
28
- }
29
-
30
19
  // Parse options from command line argument
31
20
  const optionsJson = process.argv[2];
32
21
  if (!optionsJson) {
@@ -44,14 +33,6 @@ logger.info('Background recording process started', {
44
33
  options
45
34
  });
46
35
 
47
- // Write PID file immediately
48
- try {
49
- fs.writeFileSync(PID_FILE, process.pid.toString());
50
- logger.info('PID file written', { path: PID_FILE, pid: process.pid });
51
- } catch (error) {
52
- logger.error('Failed to write PID file', { error });
53
- }
54
-
55
36
  // Write status file
56
37
  function writeStatus(status) {
57
38
  try {
@@ -8,12 +8,8 @@ import { logger } from './logger.js';
8
8
  const __filename = fileURLToPath(import.meta.url);
9
9
  const __dirname = path.dirname(__filename);
10
10
 
11
- // Use a fixed system-wide directory for cross-process communication
12
- // On Windows: C:\ProgramData\dashcam-cli
13
- // On Unix: /tmp/dashcam-cli
14
- const PROCESS_DIR = process.platform === 'win32'
15
- ? path.join('C:', 'ProgramData', 'dashcam-cli')
16
- : path.join('/tmp', 'dashcam-cli');
11
+ // Use a fixed directory in the user's home directory for cross-process communication
12
+ const PROCESS_DIR = path.join(os.homedir(), '.dashcam-cli');
17
13
  const PID_FILE = path.join(PROCESS_DIR, 'recording.pid');
18
14
  const STATUS_FILE = path.join(PROCESS_DIR, 'status.json');
19
15
  const RESULT_FILE = path.join(PROCESS_DIR, 'upload-result.json');
@@ -115,23 +111,16 @@ class ProcessManager {
115
111
  }
116
112
 
117
113
  isRecordingActive() {
114
+ const pid = this.readPid();
118
115
  const status = this.readStatus();
119
116
 
120
- if (!status || !status.pid) {
117
+ if (!pid || !this.isProcessRunning(pid)) {
121
118
  // Clean up but preserve upload result in case the background process just finished uploading
122
119
  this.cleanup({ preserveResult: true });
123
120
  return false;
124
121
  }
125
122
 
126
- const pid = status.pid;
127
-
128
- if (!this.isProcessRunning(pid)) {
129
- // Clean up but preserve upload result in case the background process just finished uploading
130
- this.cleanup({ preserveResult: true });
131
- return false;
132
- }
133
-
134
- return status.isRecording;
123
+ return status && status.isRecording;
135
124
  }
136
125
 
137
126
  getActiveStatus() {
@@ -160,14 +149,13 @@ class ProcessManager {
160
149
 
161
150
  try {
162
151
  const status = this.readStatus();
152
+ const pid = this.readPid();
163
153
 
164
154
  if (!status || !status.isRecording) {
165
155
  logger.warn('No active recording found');
166
156
  return false;
167
157
  }
168
158
 
169
- const pid = status.pid;
170
-
171
159
  if (!pid || !this.isProcessRunning(pid)) {
172
160
  logger.warn('Background process not running');
173
161
  this.cleanup({ preserveResult: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dashcam",
3
- "version": "1.3.9-beta",
3
+ "version": "1.3.12-beta",
4
4
  "description": "Minimal CLI version of Dashcam desktop app",
5
5
  "main": "bin/dashcam.js",
6
6
  "bin": {