@@ -17,6 +17,10 @@ import { webapp_client } from "@cocalc/frontend/webapp-client";
17
17
import { map as awaitMap } from "awaiting" ;
18
18
import { getComputeServers } from "./synctable" ;
19
19
import { join } from "path" ;
20
+ import {
21
+ computeServerManager ,
22
+ type ComputeServerManager ,
23
+ } from "@cocalc/conat/compute/manager" ;
20
24
21
25
declare var DEBUG : boolean ;
22
26
@@ -388,24 +392,34 @@ export class ComputeActions {
388
392
}
389
393
const course_project_id = store . get ( "course_project_id" ) ;
390
394
395
+ let studentAssociations : null | ComputeServerManager = null ;
396
+ // project_client.computeServers can only be used for tabs
397
+ // for a project that is actually open in the client, so
398
+ // we use it for the instructor project, but not the student
399
+ // project, which may not be opened.
391
400
const courseAssociations =
392
401
webapp_client . project_client . computeServers ( course_project_id ) ;
393
402
394
- const studentAssociations =
395
- webapp_client . project_client . computeServers ( target_project_id ) ;
403
+ try {
404
+ studentAssociations = computeServerManager ( {
405
+ project_id : target_project_id ,
406
+ } ) ;
396
407
397
- const ids = await courseAssociations . getServerIdForSubtree ( src_path ) ;
398
- for ( const source in ids ) {
399
- if ( ids [ source ] ) {
400
- const tail = source . slice ( src_path . length + 1 ) ;
401
- const path = join ( target_path , tail ) ;
402
- await studentAssociations . waitUntilReady ( ) ;
403
- // path is on a compute server.
404
- studentAssociations . connectComputeServerToPath ( {
405
- id : compute_server_id ,
406
- path,
407
- } ) ;
408
+ const ids = await courseAssociations . getServerIdForSubtree ( src_path ) ;
409
+ for ( const source in ids ) {
410
+ if ( ids [ source ] ) {
411
+ const tail = source . slice ( src_path . length + 1 ) ;
412
+ const path = join ( target_path , tail ) ;
413
+ await studentAssociations . waitUntilReady ( ) ;
414
+ // path is on a compute server.
415
+ studentAssociations . connectComputeServerToPath ( {
416
+ id : compute_server_id ,
417
+ path,
418
+ } ) ;
419
+ }
408
420
}
421
+ } finally {
422
+ studentAssociations ?. close ( ) ;
409
423
}
410
424
} ;
411
425
}
0 commit comments