Skip to content

Commit

Permalink
fix: use sym link
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Aug 11, 2019
1 parent e023c3a commit 3b593f1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
26 changes: 17 additions & 9 deletions src/main/store/modules/launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ const mod = {
await fs.mkdir(dir);
}
const files = await fs.readdir(dir);
await Promise.all(files.map(file => fs.unlink(join(dir, file))));
for (const file of files) {
const fp = join(dir, file);
const isLink = await fs.stat(fp).then(s => s.isSymbolicLink());
if (isLink) {
await fs.unlink(fp);
}
}
await dispatch('deployResources', {
resourceUrls: profile.deployments[domain],
profile: profile.id,
Expand All @@ -121,12 +127,16 @@ const mod = {
}
}

// we link the resource pack whatever
await dispatch('deployResources', {
resourceUrls: rootGetters.resourcepacks.map(r => r.hash),
profile: profile.id,
});

try {
// we link the resource pack whatever
await dispatch('deployResources', {
resourceUrls: rootGetters.resourcepacks.map(r => r.hash),
profile: profile.id,
});
} catch (e) {
console.error('Cannot deploy resource packs');
console.error(e);
}
console.log('Launching with these option...');
console.log(JSON.stringify(option));

Expand Down Expand Up @@ -163,7 +173,6 @@ const mod = {
});
process.stdout.on('data', (s) => {
const string = s.toString();
console.log(string);
if (string.indexOf('---- Minecraft Crash Report ----') !== -1) {
crashReport = string;
} else if (string.indexOf('Crash report saved to:') !== -1) {
Expand All @@ -176,7 +185,6 @@ const mod = {
ipcMain.emit('minecraft-stdout', string);
});
process.stderr.on('data', (s) => {
console.log(s.toString());
ipcMain.emit('minecraft-stderr', s.toString());
});
process.unref();
Expand Down
4 changes: 2 additions & 2 deletions src/main/store/modules/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,12 @@ const mod = {
const stat = await fs.stat(dest);
if (stat.isSymbolicLink()) {
await fs.unlink(dest);
promises.push(fs.link(res.path, dest));
promises.push(fs.symlink(res.path, dest));
} else {
console.error(`Cannot deploy resource ${res.hash} -> ${dest}, since the path is occupied.`);
}
} catch (e) {
promises.push(fs.link(res.path, dest));
promises.push(fs.symlink(res.path, dest));
}
} else if (res.domain === 'saves') {
await context.dispatch('importSave', res.path);
Expand Down

0 comments on commit 3b593f1

Please sign in to comment.