Skip to content

Commit

Permalink
refactor: there is no need to call remove before copying the file
Browse files Browse the repository at this point in the history
Signed-off-by: The1111mp <[email protected]>
  • Loading branch information
1111mp committed Apr 9, 2024
1 parent 318aac8 commit 2751914
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/main/utils/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ async function updateToSchemaVersionLast(version: number) {
if (platform !== "win32") {
const targetFile = join(BIN_DIR, "nvmd");

await remove(targetFile);

const sourceFile = app.isPackaged
? join(process.resourcesPath, "assets", "sources", "nvmd")
: join(__dirname, "../../..", "assets", "sources", "nvmd");
Expand All @@ -100,27 +98,17 @@ async function updateToSchemaVersionLast(version: number) {
}

// Windows
const targetFile = join(BIN_DIR, "nvmd.exe");

await remove(targetFile);

const sourceFile = app.isPackaged
? join(process.resourcesPath, "assets", "sources", `${arch}.exe`)
: join(__dirname, "../../..", "assets", "sources", `${arch}.exe`);
await copy(sourceFile, targetFile).catch((_err) => {});
await copy(sourceFile, join(BIN_DIR, "nvmd.exe")).catch((_err) => {});

async function updateFile(fileName: string) {
const filePath = join(BIN_DIR, fileName);

await remove(filePath);

await copy(sourceFile, filePath).catch((_err) => {});

await copy(sourceFile, join(BIN_DIR, fileName)).catch((_err) => {});
return;
}

const files = await readdir(BIN_DIR);

await Promise.all(
files.filter((name) => name.endsWith(".exe")).map((fileName) => updateFile(fileName))
);
Expand Down
Empty file.

0 comments on commit 2751914

Please sign in to comment.