-
Notifications
You must be signed in to change notification settings - Fork 0
/
ResoniteCacheCleanUp.js
31 lines (27 loc) · 1.02 KB
/
ResoniteCacheCleanUp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const fs = require('fs');
const path = require('path');
const os = require('os');
const limit = new Date();
limit.setDate(limit.getDate() - 7);
const userProfile = os.homedir();
const path1 = path.join(userProfile, 'AppData', 'LocalLow', 'Yellow Dog Man Studios', 'Resonite', 'Assets');
const path2 = path.join(userProfile, 'AppData', 'Local', 'Temp', 'Yellow Dog Man Studios', 'Resonite', 'Cache');
cleanFolder(path1);
cleanFolder(path2);
function cleanFolder(folderPath) {
if (fs.existsSync(folderPath)) {
fs.readdirSync(folderPath).forEach((file) => {
const filePath = path.join(folderPath, file);
const stats = fs.statSync(filePath);
if (stats.atime < limit) {
if (stats.isFile()) {
fs.unlinkSync(filePath);
console.log(`Deleted file: ${filePath}`);
} else if (stats.isDirectory()) {
fs.rmdirSync(filePath, { recursive: true });
console.log(`Deleted directory and its contents: ${filePath}`);
}
}
});
}
}