@@ -8,6 +8,7 @@ FileRecoveryService = require './file-recovery-service'
8
8
ipcHelpers = require ' ../ipc-helpers'
9
9
{BrowserWindow , Menu , app , dialog , ipcMain , shell , screen } = require ' electron'
10
10
{CompositeDisposable , Disposable } = require ' event-kit'
11
+ crypto = require ' crypto'
11
12
fs = require ' fs-plus'
12
13
path = require ' path'
13
14
os = require ' os'
@@ -33,11 +34,16 @@ class AtomApplication
33
34
# Public: The entry point into the Atom application.
34
35
@ open: (options ) ->
35
36
unless options .socketPath ?
37
+ username = if process .platform is ' win32' then process .env .USERNAME else process .env .USER
38
+ # Lowercasing the ATOM_HOME to make sure that we don't get multiple sockets
39
+ # on case-insensitive filesystems due to arbitrary case differences in paths.
40
+ atomHomeUnique = path .resolve (process .env .ATOM_HOME ).toLowerCase ()
41
+ hash = crypto .createHash (' sha1' ).update (username).update (' |' ).update (atomHomeUnique)
42
+ atomInstanceDigest = hash .digest (' hex' ).substring (0 , 32 )
36
43
if process .platform is ' win32'
37
- userNameSafe = new Buffer (process .env .USERNAME ).toString (' base64' )
38
- options .socketPath = " \\\\ .\\ pipe\\ atom-#{ options .version } -#{ userNameSafe} -#{ process .arch } -sock"
44
+ options .socketPath = " \\\\ .\\ pipe\\ atom-#{ options .version } -#{ process .arch } -#{ atomInstanceDigest} -sock"
39
45
else
40
- options .socketPath = path .join (os .tmpdir (), " atom-#{ options .version } -#{ process .env . USER } .sock" )
46
+ options .socketPath = path .join (os .tmpdir (), " atom-#{ options .version } -#{ process .arch } - #{ atomInstanceDigest } .sock" )
41
47
42
48
# FIXME: Sometimes when socketPath doesn't exist, net.connect would strangely
43
49
# take a few seconds to trigger 'error' event, it could be a bug of node
0 commit comments