Skip to content

Commit

Permalink
fix: warn when the projectRoot is not writeable
Browse files Browse the repository at this point in the history
closes #18485
  • Loading branch information
elevatebart committed Oct 14, 2021
1 parent 7aac450 commit 6889b11
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/server/lib/modes/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,22 @@ const openProjectCreate = (projectRoot, socketId, args) => {
return openProject.create(projectRoot, args, options)
}

const createAndOpenProject = async function (socketId, options) {
async function checkAccess (folderPath) {
return fs.access(folderPath).catch((err) => {
if (['EACCES', 'EPERM'].includes(err.code)) {
// we cannot write due to folder permissions
return errors.warning('FOLDER_NOT_WRITABLE', folderPath)
}

throw err
})
}

const createAndOpenProject = async (socketId, options) => {
const { projectRoot, projectId } = options

await checkAccess(projectRoot)

return openProjectCreate(projectRoot, socketId, options)
.then((open_project) => open_project.getProject())
.then((project) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/server/test/e2e/non_root_read_only_fs_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ describe('e2e readonly fs', function () {

const projectPath = Fixtures.projectPath('read-only-project-root')

/**
* Change permissions recursively
*/
const chmodr = (p: string, mode: number) => {
const stats = fs.statSync(p)

Expand Down

0 comments on commit 6889b11

Please sign in to comment.