File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change 1
1
import { createHash } from "crypto" ;
2
+ import { join } from "node:path" ;
2
3
3
4
import { projects } from "@cocalc/backend/data" ;
4
5
import { is_valid_uuid_string } from "@cocalc/util/misc" ;
@@ -74,5 +75,11 @@ export function envForSpawn() {
74
75
75
76
// return the absolute home directory of given @project_id project on disk
76
77
export function homePath ( project_id : string ) : string {
77
- return projects . replace ( "[project_id]" , project_id ) ;
78
+ // $MOUNTED_PROJECTS_ROOT is for OnPrem and that "projects" location is only for dev/single-user
79
+ const projects_root = process . env . MOUNTED_PROJECTS_ROOT ;
80
+ if ( projects_root ) {
81
+ return join ( projects_root , project_id ) ;
82
+ } else {
83
+ return projects . replace ( "[project_id]" , project_id ) ;
84
+ }
78
85
}
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ Code related to permanently deleting projects.
8
8
*/
9
9
10
10
import { promises as fs } from "node:fs" ;
11
- import { join } from "node:path" ;
12
11
13
12
import { pathToFiles } from "@cocalc/backend/files/path-to-files" ;
14
13
import getLogger , { WinstonLogger } from "@cocalc/backend/logger" ;
@@ -301,12 +300,7 @@ async function deleteProjectFiles(
301
300
L2 : WinstonLogger [ "debug" ] ,
302
301
project_id : string ,
303
302
) {
304
- // $MOUNTED_PROJECTS_ROOT is for OnPrem and homePath only works in dev/single-user
305
- const projects_root =
306
- process . env [ "MOUNTED_PROJECTS_ROOT" ] ?? homePath ( project_id ) ;
307
- if ( ! projects_root ) return ;
308
- const project_dir = join ( projects_root , project_id ) ;
309
- L2 ( `attempting to delete all files in ${ project_dir } ` ) ;
303
+ const project_dir = homePath ( project_id ) ;
310
304
try {
311
305
await fs . access ( project_dir , F_OK | R_OK | W_OK ) ;
312
306
const stats = await fs . lstat ( project_dir ) ;
@@ -318,7 +312,7 @@ async function deleteProjectFiles(
318
312
}
319
313
} catch ( err ) {
320
314
L2 (
321
- `not deleting project files: either path does not exist or is not accessible` ,
315
+ `not deleting project files: either ' ${ project_dir } ' does not exist or is not accessible` ,
322
316
) ;
323
317
}
324
318
}
You can’t perform that action at this time.
0 commit comments