A simple, zero-configuration script to quickly boot FreeBSD ISO images using QEMU

Merge pull request #1 from tsirysndr/fix/empty-disk-threshold

Refactor disk size checks to use EMPTY_DISK_THRESHOLD_KB constant

authored by tsiry-sandratraina.com and committed by

GitHub 7747c267 9f03a5e3

+4 -3
+1
src/constants.ts
··· 1 1 export const CONFIG_DIR: string = `${Deno.env.get("HOME")}/.freebsd-up`; 2 2 export const DB_PATH: string = `${CONFIG_DIR}/state.sqlite`; 3 3 export const LOGS_DIR: string = `${CONFIG_DIR}/logs`; 4 + export const EMPTY_DISK_THRESHOLD_KB: number = 100;
+3 -3
src/utils.ts
··· 2 2 import chalk from "chalk"; 3 3 import _ from "lodash"; 4 4 import Moniker from "moniker"; 5 - import { LOGS_DIR } from "./constants.ts"; 5 + import { EMPTY_DISK_THRESHOLD_KB, LOGS_DIR } from "./constants.ts"; 6 6 import { generateRandomMacAddress } from "./network.ts"; 7 7 import { saveInstanceState, updateInstanceState } from "./state.ts"; 8 8 ··· 40 40 } 41 41 42 42 const size = await du(path); 43 - return size < 100; 43 + return size < EMPTY_DISK_THRESHOLD_KB; 44 44 } 45 45 46 46 export async function downloadIso( ··· 52 52 53 53 if (options.image && await Deno.stat(options.image).catch(() => false)) { 54 54 const driveSize = await du(options.image); 55 - if (driveSize > 10) { 55 + if (driveSize > EMPTY_DISK_THRESHOLD_KB) { 56 56 console.log( 57 57 chalk.yellowBright( 58 58 `Drive image ${options.image} is not empty (size: ${driveSize} KB), skipping ISO download to avoid overwriting existing data.`,