1- import { rm , writeFile } from "fs/promises"
1+ import { rm , writeFile , mkdir } from "fs/promises"
22import { readFile , access , constants , copyFile } from "fs/promises"
33
4- const HARDWARE_PATH = "/home/pi/hardware.json"
5- const SOFTWARE_PATH = "/home/pi/config.json"
6- const CALIBRATION_PATH = "/home/pi/calibration.json"
4+ const HARDWARE_PATH = "/home/pi/PlanktoScope/ hardware.json"
5+ const SOFTWARE_PATH = "/home/pi/PlanktoScope/ config.json"
6+ const CALIBRATION_PATH = "/home/pi/PlanktoScope/ calibration.json"
77const CALIBRATION_DEFAULTS_PATH =
88 "/opt/PlanktoScope/default-configs/calibration.json"
99
@@ -17,14 +17,16 @@ async function hasConfig(path) {
1717}
1818
1919export async function initConfigFiles ( hardware_version ) {
20+ await mkdir ( "/home/pi/PlanktoScope" )
21+
2022 await Promise . all ( [
2123 copyFile (
2224 `/opt/PlanktoScope/default-configs/${ hardware_version } .config.json` ,
23- "/home/pi/config.json" ,
25+ SOFTWARE_PATH ,
2426 ) ,
2527 copyFile (
2628 `/opt/PlanktoScope/default-configs/${ hardware_version } .hardware.json` ,
27- "/home/pi/hardware.json" ,
29+ HARDWARE_PATH ,
2830 ) ,
2931 // Create calibration.json from defaults if it doesn't exist yet.
3032 // Unlike config/hardware, this never overwrites — preserving user calibrations.
0 commit comments