Skip to content

Commit

Permalink
Unlink the file THEN symlink.
Browse files Browse the repository at this point in the history
Closes #9

The issue is that /tmp/mysql.lock isn't being unlink'd fast enough by the system before the symlinking process begins. I should have done this to begin with, but we don't symlink now UNTIL after the unlink process finishes.

Essentially a race-condition.
  • Loading branch information
aubreypwd committed Feb 26, 2021
1 parent 2ca4816 commit 7a2533a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/TablePlus.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,25 @@ 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 <aubrey@webdevstudios.com>
* @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.
*
* @author Aubrey Portwood <aubrey@webdevstudios.com>
* @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);
}

Expand All @@ -161,7 +171,7 @@ export default class TablePlus extends React.Component {
* @return {void}
*/
openTablePlus () {
this.symlinkSockFile();
this.unlinkAndThenSymlinkTmpSockFile();
this.openURI();
}

Expand Down

0 comments on commit 7a2533a

Please sign in to comment.