small bugfixes #18
|
@ -264,23 +264,28 @@ async function getEZPPLauncherUpdateFiles(osuPath) {
|
|||
filesToDownload.push(updateFile);
|
||||
}
|
||||
}
|
||||
return filesToDownload;
|
||||
return [filesToDownload, updateFiles];
|
||||
}
|
||||
|
||||
async function downloadEZPPLauncherUpdateFiles(osuPath, updateFiles) {
|
||||
async function downloadEZPPLauncherUpdateFiles(osuPath, updateFiles, allFiles) {
|
||||
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);
|
||||
const foldersToPrune = allFiles.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) {
|
||||
console.log("Pruning folder:", pruneFolder);
|
||||
//NOTE: check if the folder is not the osu root folder.
|
||||
if (path.basename(pruneFolder) == "osu!")
|
||||
continue;
|
||||
if (fs.existsSync(pruneFolder)) {
|
||||
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)) {
|
||||
const validFolder = allFiles.find(file => path.dirname(filePath).endsWith(file.folder));
|
||||
if (!validFolder) {
|
||||
if (allFiles.find(file => file.name == path.basename(filePath)) === undefined) {
|
||||
console.log("Deleting file:", filePath);
|
||||
console.log(allFiles.find(file => file.name == path.basename(filePath)));
|
||||
eventEmitter.emit("data", {
|
||||
fileName: path.basename(filePath),
|
||||
});
|
||||
|
@ -291,6 +296,7 @@ async function downloadEZPPLauncherUpdateFiles(osuPath, updateFiles) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const updateFile of updateFiles) {
|
||||
try {
|
||||
|
|
3
main.js
3
main.js
|
@ -557,12 +557,13 @@ function registerIPCPipes() {
|
|||
status: "Looking for patcher updates...",
|
||||
});
|
||||
await new Promise((res) => setTimeout(res, 1000));
|
||||
const patchFiles = await getEZPPLauncherUpdateFiles(osuPath);
|
||||
const [patchFiles, allUpdateFiles] = await getEZPPLauncherUpdateFiles(osuPath);
|
||||
if (patchFiles.length > 0) {
|
||||
logger.log("EZPPLauncher updates found.");
|
||||
const patcherDownloader = await downloadEZPPLauncherUpdateFiles(
|
||||
osuPath,
|
||||
patchFiles,
|
||||
allUpdateFiles
|
||||
);
|
||||
let errored = false;
|
||||
patcherDownloader.eventEmitter.on("error", (data) => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user