diff --git a/src/TablePlus.js b/src/TablePlus.js index ae363f5..1a210a0 100644 --- a/src/TablePlus.js +++ b/src/TablePlus.js @@ -138,6 +138,17 @@ export default class TablePlus extends React.Component { exec(`open "${this.getTablePlusURI()}"`, () => this.doNothing()); } + /** + * Reset /tmp/mysql.lock then symlink the socket file. + * + * @author Aubrey Portwood + * @since 1.0.2 + * @return {void} + */ + unlinkAndThenSymlinkTmpSockFile () { + fs.unlink('/tmp/mysql.sock', () => this.symlinkTmpSockFile()); + } + /** * Symlink the /tmp/mysql.sock file to the site sock file. * @@ -145,8 +156,7 @@ export default class TablePlus extends React.Component { * @since 1.0.0 * @return {void} */ - symlinkSockFile () { - fs.unlink('/tmp/mysql.sock', () => this.doNothing()); + symlinkTmpSockFile () { fs.symlinkSync(this.getSockFile(), '/tmp/mysql.sock', 'file', this.doNothing); } @@ -161,7 +171,7 @@ export default class TablePlus extends React.Component { * @return {void} */ openTablePlus () { - this.symlinkSockFile(); + this.unlinkAndThenSymlinkTmpSockFile(); this.openURI(); }