diff --git a/src/constants.ts b/src/constants.ts index cd2f522..31d560a 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,3 +1,4 @@ export const CONFIG_DIR: string = `${Deno.env.get("HOME")}/.openbsd-up`; export const DB_PATH: string = `${CONFIG_DIR}/state.sqlite`; export const LOGS_DIR: string = `${CONFIG_DIR}/logs`; +export const EMPTY_DISK_SIZE_KB = 100; diff --git a/src/utils.ts b/src/utils.ts index 328d6d2..39d0561 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,7 +2,7 @@ import { createId } from "@paralleldrive/cuid2"; import chalk from "chalk"; import _ from "lodash"; import Moniker from "moniker"; -import { LOGS_DIR } from "./constants.ts"; +import { EMPTY_DISK_SIZE_KB, LOGS_DIR } from "./constants.ts"; import { generateRandomMacAddress } from "./network.ts"; import { saveInstanceState, updateInstanceState } from "./state.ts"; @@ -40,7 +40,7 @@ export async function emptyDiskImage(path: string): Promise { } const size = await du(path); - return size < 100; + return size < EMPTY_DISK_SIZE_KB; } export async function downloadIso( @@ -52,7 +52,7 @@ export async function downloadIso( if (options.image && await Deno.stat(options.image).catch(() => false)) { const driveSize = await du(options.image); - if (driveSize > 10) { + if (driveSize > EMPTY_DISK_SIZE_KB) { console.log( chalk.yellowBright( `Drive image ${options.image} is not empty (size: ${driveSize} KB), skipping ISO download to avoid overwriting existing data.`,