mirror of
https://github.com/WowUp/WowUp.git
synced 2026-04-29 02:07:55 -04:00
Merge pull request #1017 from WowUp/hotfix/block-ownner
Cherry pick the blocklist owner check
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { exec } from "child_process";
|
||||
import * as log from "electron-log";
|
||||
import * as fs from "fs-extra";
|
||||
import * as path from "path";
|
||||
import * as fsp from "fs/promises";
|
||||
import { max } from "lodash";
|
||||
import * as path from "path";
|
||||
|
||||
import { isWin } from "./platform";
|
||||
|
||||
export async function readDirRecursive(sourcePath: string): Promise<string[]> {
|
||||
const dirFiles: string[] = [];
|
||||
@@ -30,3 +35,33 @@ export async function getLastModifiedFileDate(sourcePath: string): Promise<numbe
|
||||
const latest = max(dates);
|
||||
return latest;
|
||||
}
|
||||
|
||||
export async function remove(path: string): Promise<void> {
|
||||
const stat = await fsp.stat(path);
|
||||
if (stat.isDirectory()) {
|
||||
await rmdir(path);
|
||||
} else {
|
||||
await fsp.unlink(path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On Windows, users that use the Google Drive sync tool are unable to delete any folders.
|
||||
* Seems to be a node issue that it cannot delete even empty folders synced by this tool.
|
||||
* However, if you use CMD to delete the folder it works fine?
|
||||
*/
|
||||
async function rmdir(path: string): Promise<void> {
|
||||
if (isWin) {
|
||||
await new Promise((resolve, reject) => {
|
||||
exec(`rmdir "${path}" /s /q`, (err, stdout, stderr) => {
|
||||
if (err || stdout.length || stderr.length) {
|
||||
log.error("rmdir fallback failed", err, stdout, stderr);
|
||||
return reject(new Error("rmdir fallback failed"));
|
||||
}
|
||||
resolve(undefined);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
await fsp.rm(path, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ import { RendererChannels } from "../src/common/wowup";
|
||||
import { MenuConfig, SystemTrayConfig, WowUpScanResult } from "../src/common/wowup/models";
|
||||
import { createAppMenu } from "./app-menu";
|
||||
import { CurseFolderScanner } from "./curse-folder-scanner";
|
||||
import { getLastModifiedFileDate } from "./file.utils";
|
||||
import { getLastModifiedFileDate, remove } from "./file.utils";
|
||||
import { addonStore } from "./stores";
|
||||
import { createTray, restoreWindow } from "./system-tray";
|
||||
import { WowUpFolderScanner } from "./wowup-folder-scanner";
|
||||
@@ -359,11 +359,7 @@ export function initializeIpcHandlers(window: BrowserWindow, userAgent: string):
|
||||
|
||||
handle(IPC_DELETE_DIRECTORY_CHANNEL, async (evt, filePath: string) => {
|
||||
log.info(`[FileRemove] ${filePath}`);
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.remove(filePath, (err) => {
|
||||
return err ? reject(err) : resolve(true);
|
||||
});
|
||||
});
|
||||
return await remove(filePath);
|
||||
});
|
||||
|
||||
handle(IPC_READ_FILE_CHANNEL, async (evt, filePath: string) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "wowup",
|
||||
"productName": "WowUp",
|
||||
"version": "2.4.4",
|
||||
"version": "2.4.5",
|
||||
"description": "World of Warcraft addon updater",
|
||||
"homepage": "https://wowup.io",
|
||||
"author": {
|
||||
|
||||
@@ -682,6 +682,11 @@ export class CurseAddonProvider extends AddonProvider {
|
||||
}
|
||||
|
||||
private async isBlockedAuthor(author: CurseAuthor) {
|
||||
// It looks like if the author is the owner the titleId is just null
|
||||
if (author?.projectTitleId !== null && author?.projectTitleTitle !== null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const blockList = await this._wowupApiService.getBlockList().toPromise();
|
||||
const blockedAuthorIds = _.map(blockList.curse.authors, (author) => author.authorId);
|
||||
|
||||
@@ -15,6 +15,17 @@ export class PatchNotesService {
|
||||
}
|
||||
|
||||
const CHANGELOGS: ChangeLog[] = [
|
||||
{
|
||||
Version: "2.4.5",
|
||||
html: `
|
||||
<div>
|
||||
<h4 style="margin-top: 1em;">Fixes</h4>
|
||||
<ul>
|
||||
<li>Fix an issue with Google Drive preventing files from being deleted</li>
|
||||
<li>Fix an issue with checking addon owners against the block list</li>
|
||||
</ul>
|
||||
</div>`,
|
||||
},
|
||||
{
|
||||
Version: "2.4.4",
|
||||
html: `
|
||||
|
||||
Reference in New Issue
Block a user