clean up unneeded files
This commit is contained in:
parent
9da481b991
commit
80343bd929
|
@ -271,6 +271,17 @@ async function downloadEZPPLauncherUpdateFiles(osuPath, updateFiles) {
|
|||
const eventEmitter = new EventEmitter();
|
||||
|
||||
const startDownload = async () => {
|
||||
//NOTE: delete files that are not in the updateFiles array
|
||||
const foldersToPrune = updateFiles.map(file => path.dirname(path.join(osuPath, ...file.folder.split("/"), file.name))).filter((folder, index, self) => self.indexOf(folder) === index);
|
||||
for (const pruneFolder of foldersToPrune) {
|
||||
for (const files of await fs.promises.readdir(pruneFolder)) {
|
||||
const filePath = path.join(pruneFolder, files);
|
||||
if (!updateFiles.some(file => path.join(osuPath, ...file.folder.split("/"), file.name) === filePath)) {
|
||||
await fs.promises.rm(filePath, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const updateFile of updateFiles) {
|
||||
try {
|
||||
const filePath = path.join(
|
||||
|
|
Loading…
Reference in New Issue
Block a user