Skip to content

Commit

Permalink
refactor: remove old user folder stuff for mac
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilNarayana committed Aug 10, 2023
1 parent 0a7c61a commit ca0f4a1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
7 changes: 0 additions & 7 deletions src/dolphin/install/installation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,9 @@ export class DolphinInstallation {
}
case "darwin": {
const { installDolphinOnMac } = await import("./macos");
const currentVersion = await this.getDolphinVersion();
const userFolderInBundle = currentVersion !== null && lt(currentVersion, "3.0.5");
if (userFolderInBundle) {
const oldUserFolder = path.join(dolphinPath, "Slippi Dolphin.app", "Contents", "Resources", "User");
await fs.copy(oldUserFolder, this.userFolder, { recursive: true, overwrite: true });
}
await installDolphinOnMac({
assetPath,
destinationFolder: dolphinPath,
shouldBackupUserFolder: userFolderInBundle,
});
break;
}
Expand Down
23 changes: 0 additions & 23 deletions src/dolphin/install/macos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,12 @@ import { extractDmg } from "./extractDmg";
export async function installDolphinOnMac({
assetPath,
destinationFolder,
shouldBackupUserFolder,
log = console.log,
}: {
assetPath: string;
destinationFolder: string;
shouldBackupUserFolder?: boolean;
log?: (message: string) => void;
}) {
const backupLocation = destinationFolder + "_old";
const dolphinResourcesPath = path.join(destinationFolder, "Slippi Dolphin.app", "Contents", "Resources");

const backupUserFolder = shouldBackupUserFolder && (await fs.pathExists(dolphinResourcesPath));
if (backupUserFolder) {
log(`${dolphinResourcesPath} already exists. Moving...`);
await fs.move(destinationFolder, backupLocation, { overwrite: true });
}

log(`Extracting to: ${destinationFolder}`);
await extractDmg(assetPath, destinationFolder);
const files = await fs.readdir(destinationFolder);
Expand All @@ -42,16 +31,4 @@ export async function installDolphinOnMac({
await fs.chown(path.join(destinationFolder, "Slippi Dolphin.app"), userInfo.uid, userInfo.gid);
await fs.chmod(binaryLocation, "777");
await fs.chown(binaryLocation, userInfo.uid, userInfo.gid);

// move backed up User folder and user.json
if (backupUserFolder) {
const oldUserFolder = path.join(backupLocation, "Slippi Dolphin.app", "Contents", "Resources", "User");
const newUserFolder = path.join(dolphinResourcesPath, "User");
log("moving User folder...");
const hasUserFolder = await fs.pathExists(oldUserFolder);
if (hasUserFolder) {
await fs.move(oldUserFolder, newUserFolder);
}
await fs.remove(backupLocation);
}
}

0 comments on commit ca0f4a1

Please sign in to comment.