Skip to content

Commit 990cc14

Browse files
committed
Fix: update backup path and ensure log and backup directories are created if missing
1 parent 225de2c commit 990cc14

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

main.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,22 @@ const { type } = require("os");
55
const { measureMemory } = require("vm");
66

77
const file_path = "data-karyawan.txt";
8-
const backup_path = "data-karyawan-backup.txt";
8+
const backup_path = "backup/data-karyawan-backup.txt";
99
const log_path = "logs/data-terhapus.txt";
1010

1111
if (!fs.existsSync(file_path)) {
1212
console.warn(`File "${file_path}" tidak ditemukan. Membuat file baru...`);
1313
fs.writeFileSync(file_path, "");
1414
}
1515

16+
if (!fs.existsSync("logs")) {
17+
fs.mkdirSync("logs");
18+
}
19+
20+
if (!fs.existsSync("backup")) {
21+
fs.mkdirSync("backup");
22+
}
23+
1624
let isi_file = "";
1725

1826
try {
@@ -592,10 +600,6 @@ async function delete_data() {
592600

593601
backup_data();
594602

595-
if (!fs.existsSync("logs")) {
596-
fs.mkdirSync("logs");
597-
}
598-
599603
try {
600604
fs.appendFileSync(
601605
log_path,

0 commit comments

Comments
 (0)