dashcam 1.0.1-beta.3 → 1.0.1-beta.4
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 +17 -1
- package/lib/processManager.js +25 -0
- package/package.json +1 -1
package/bin/dashcam.js
CHANGED
|
@@ -171,6 +171,12 @@ program
|
|
|
171
171
|
snapshotPath: stopResult.snapshotPath
|
|
172
172
|
});
|
|
173
173
|
|
|
174
|
+
// Write upload result for stop command to read
|
|
175
|
+
processManager.writeUploadResult({
|
|
176
|
+
shareLink: uploadResult.shareLink,
|
|
177
|
+
replayId: uploadResult.replay?.id
|
|
178
|
+
});
|
|
179
|
+
|
|
174
180
|
log('✅ Upload complete!');
|
|
175
181
|
log('📹 Watch your recording:', uploadResult.shareLink);
|
|
176
182
|
}
|
|
@@ -302,7 +308,17 @@ program
|
|
|
302
308
|
|
|
303
309
|
if (!filesExist) {
|
|
304
310
|
console.log('✅ Recording was already uploaded by background process');
|
|
305
|
-
|
|
311
|
+
|
|
312
|
+
// Try to read the upload result from the background process
|
|
313
|
+
const uploadResult = processManager.readUploadResult();
|
|
314
|
+
if (uploadResult && uploadResult.shareLink) {
|
|
315
|
+
console.log('✅ Recording stopped and uploaded');
|
|
316
|
+
console.log('📹 Watch your recording:', uploadResult.shareLink);
|
|
317
|
+
} else {
|
|
318
|
+
console.log('✅ Recording stopped and uploaded');
|
|
319
|
+
logger.warn('Upload result not available from background process');
|
|
320
|
+
}
|
|
321
|
+
|
|
306
322
|
process.exit(0);
|
|
307
323
|
}
|
|
308
324
|
|
package/lib/processManager.js
CHANGED
|
@@ -8,6 +8,7 @@ import { logger } from './logger.js';
|
|
|
8
8
|
const PROCESS_DIR = path.join(os.homedir(), '.dashcam-cli');
|
|
9
9
|
const PID_FILE = path.join(PROCESS_DIR, 'recording.pid');
|
|
10
10
|
const STATUS_FILE = path.join(PROCESS_DIR, 'status.json');
|
|
11
|
+
const RESULT_FILE = path.join(PROCESS_DIR, 'upload-result.json');
|
|
11
12
|
|
|
12
13
|
// Ensure process directory exists
|
|
13
14
|
if (!fs.existsSync(PROCESS_DIR)) {
|
|
@@ -47,6 +48,29 @@ class ProcessManager {
|
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
|
|
51
|
+
writeUploadResult(result) {
|
|
52
|
+
try {
|
|
53
|
+
fs.writeFileSync(RESULT_FILE, JSON.stringify({
|
|
54
|
+
...result,
|
|
55
|
+
timestamp: Date.now()
|
|
56
|
+
}, null, 2));
|
|
57
|
+
logger.debug('Wrote upload result to file', { shareLink: result.shareLink });
|
|
58
|
+
} catch (error) {
|
|
59
|
+
logger.error('Failed to write upload result file', { error });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
readUploadResult() {
|
|
64
|
+
try {
|
|
65
|
+
if (!fs.existsSync(RESULT_FILE)) return null;
|
|
66
|
+
const data = fs.readFileSync(RESULT_FILE, 'utf8');
|
|
67
|
+
return JSON.parse(data);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
logger.error('Failed to read upload result file', { error });
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
50
74
|
writePid(pid = process.pid) {
|
|
51
75
|
try {
|
|
52
76
|
fs.writeFileSync(PID_FILE, pid.toString());
|
|
@@ -96,6 +120,7 @@ class ProcessManager {
|
|
|
96
120
|
try {
|
|
97
121
|
if (fs.existsSync(PID_FILE)) fs.unlinkSync(PID_FILE);
|
|
98
122
|
if (fs.existsSync(STATUS_FILE)) fs.unlinkSync(STATUS_FILE);
|
|
123
|
+
if (fs.existsSync(RESULT_FILE)) fs.unlinkSync(RESULT_FILE);
|
|
99
124
|
} catch (error) {
|
|
100
125
|
logger.error('Failed to cleanup process files', { error });
|
|
101
126
|
}
|