fullpwerr commited on
Commit
4430937
·
1 Parent(s): 3bc9ec5
Files changed (1) hide show
  1. app.js +7 -5
app.js CHANGED
@@ -175,14 +175,13 @@ app.get("/status", (req, res) => {
175
  });
176
  });
177
 
178
-
179
  setInterval(() => {
180
  const now = Date.now();
181
  let updatedFileData = {};
182
 
183
  Object.keys(fileData).forEach(filename => {
 
184
  if (fileData[filename] <= now) {
185
- const filePath = path.join(FILE_DIR, filename);
186
  if (fs.existsSync(filePath)) {
187
  fs.unlinkSync(filePath);
188
  console.log(`🗑️ File expired dihapus: ${filename}`);
@@ -192,12 +191,15 @@ setInterval(() => {
192
  }
193
  });
194
 
195
- // Update metadata file
196
- fileData = updatedFileData;
197
- fs.writeFileSync(META_FILE, JSON.stringify(fileData));
 
 
198
  }, 60 * 60 * 1000); // Cek tiap 1 jam
199
 
200
 
 
201
  app.listen(port, () => {
202
  console.log("Listening on http://localhost:" + port);
203
  });
 
175
  });
176
  });
177
 
 
178
  setInterval(() => {
179
  const now = Date.now();
180
  let updatedFileData = {};
181
 
182
  Object.keys(fileData).forEach(filename => {
183
+ const filePath = path.join(FILE_DIR, filename);
184
  if (fileData[filename] <= now) {
 
185
  if (fs.existsSync(filePath)) {
186
  fs.unlinkSync(filePath);
187
  console.log(`🗑️ File expired dihapus: ${filename}`);
 
191
  }
192
  });
193
 
194
+ // Update metadata file hanya jika ada perubahan
195
+ if (Object.keys(updatedFileData).length !== Object.keys(fileData).length) {
196
+ fileData = updatedFileData;
197
+ fs.writeFileSync(META_FILE, JSON.stringify(fileData, null, 2));
198
+ }
199
  }, 60 * 60 * 1000); // Cek tiap 1 jam
200
 
201
 
202
+
203
  app.listen(port, () => {
204
  console.log("Listening on http://localhost:" + port);
205
  });