fix(s3): starting a member's workspace makes its missing folder, as the member
v2.7.3's ENOCWD left a new member no web path to a first project: their home is no workspace (EFOLDER) and a not-yet-existing folder could not start. run-as.makeMemberFolder: mkdir -p through write-as, AS the member, only inside their own home (never the home itself, never a host folder, never for a member with no account). Test: server-s3-lanes.
This commit is contained in:
@@ -488,6 +488,26 @@ function sameOwner(...paths) {
|
||||
|
||||
/** `mkdir -p` / `rm -rf` of a path in a member's home, AS the member. */
|
||||
const mkdirAs = (acct, dir) => writeAs(acct, dir, "mkdir");
|
||||
|
||||
/**
|
||||
* S3: make a missing workspace folder inside a member's own home, AS them
|
||||
* (`mkdir -p`, so only where they could themselves). A new member has no
|
||||
* other way to their first project: their home is no workspace (EFOLDER).
|
||||
* False — nothing made — for any other folder, the home itself, or a member
|
||||
* with no usable account.
|
||||
*/
|
||||
function makeMemberFolder(dir) {
|
||||
let acct;
|
||||
try {
|
||||
acct = accountForPath(dir);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
const abs = path.resolve(dir);
|
||||
if (!acct || abs === acct.home) return false;
|
||||
mkdirAs(acct, abs);
|
||||
return true;
|
||||
}
|
||||
const removeAs = (acct, p) => writeAs(acct, p, "remove");
|
||||
|
||||
/** `[cmd, argv]` for `command args` in `cwd`: as its member, else as is. */
|
||||
@@ -528,6 +548,7 @@ module.exports = {
|
||||
handoffWrite,
|
||||
writeAs,
|
||||
mkdirAs,
|
||||
makeMemberFolder,
|
||||
removeAs,
|
||||
launchArgv,
|
||||
sameOwner,
|
||||
|
||||
Reference in New Issue
Block a user