Add default home if user has unset $HOME env var

VFS Was constantly crashing for one user because they didn't have $HOME set in their workspace. The VFS error is:

```
2017-02-22T15:27:19Z { message: 'Scheduling process exit\nVFS Exception in function \'connect\':\n TypeError: Path must be a string. Received undefined\n    at assertPath (path.js:8:11)\n    at Object.posix.resolve (path.js:426:5)\n    at getProjectWD (eval at t ([eval]:1:364), <anonymous>:83:17)\n    at initSocket (eval at t ([eval]:1:364), <anonymous>:2925:21)\n    at Object.connect (eval at t ([eval]:1:364), <anonymous>:3126:9)\n    at Domain.eval (eval at t ([eval]:1:364), <anonymous>:4964:30)\n    at Domain.run (domain.js:228:14)\n    at Object.api.(anonymous function) [as connect] (eval at t ([eval]:1:364), <anonymous>:4963:23)\n    at Worker.call (eval at t ([eval]:1:364), <anonymous>:7909:21)\n    at Worker.Agent._onMessage (eval at t ([eval]:1:364), <anonymous>:3879:8)\nScheduling process exit\n',
  pid: 4382802 }
2017-02-22T15:27:19Z VFS stderr [4382802]: VFS Exception in function 'connect':
 TypeError: Path must be a string. Received undefined
    at assertPath (path.js:8:11)
    at Object.posix.resolve (path.js:426:5)
    at getProjectWD (eval at t ([eval]:1:364), <anonymous>:83:17)
    at initSocket (eval at t ([eval]:1:364), <anonymous>:2925:21)
    at Object.connect (eval at t ([eval]:1:364), <anonymous>:3126:9)
    at Domain.eval (eval at t ([eval]:1:364), <anonymous>:4964:30)
    at Domain.run (domain.js:228:14)
    at Object.api.(anonymous function) [as connect] (eval at t ([eval]:1:364), <anonymous>:4963:23)
    at Worker.call (eval at t ([eval]:1:364), <anonymous>:7909:21)
    at Worker.Agent._onMessage (eval at t ([eval]:1:364), <anonymous>:3879:8)
```

This fixes this bug so collab no longer crashes.
pull/402/head
Tim Robinson 2017-02-23 11:50:15 -08:00 zatwierdzone przez GitHub
rodzic 3d7c1f3302
commit 8b145e3c78
1 zmienionych plików z 3 dodań i 2 usunięć

Wyświetl plik

@ -12,6 +12,7 @@ var localfsAPI; // Set on VFS register
var DEFAULT_NL_CHAR_FILE = "\n";
var DEFAULT_NL_CHAR_DOC = "";
var MAX_WRITE_ATTEMPTS = 3;
var DEFAULT_HOME = "/home/ubuntu";
// If you leave unsaved changes for more than 24 hours and the file on disk changes
// those unsaved changes will be lost. Don't want them hanging around forever.
@ -40,13 +41,13 @@ var debug = false;
function getHomeDir() {
return process.env.HOME;
return process.env.HOME || DEFAULT_HOME;
}
function getProjectWD() {
var env = process.env;
var pidStr = env.BASE_PROC ? "" : String(PID);
return Path.resolve(env.BASE_PROC || env.HOME, ".c9", pidStr);
return Path.resolve(env.BASE_PROC || env.HOME || DEFAULT_HOME, ".c9", pidStr);
}
/**