Skip to content

Commit d580181

Browse files
committed
this should fix a bug in distributing compute server assignments and handouts
- bug was caused by distant code for reducing memory leaks
1 parent 2327d02 commit d580181

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

src/packages/frontend/course/compute/actions.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import { webapp_client } from "@cocalc/frontend/webapp-client";
1717
import { map as awaitMap } from "awaiting";
1818
import { getComputeServers } from "./synctable";
1919
import { join } from "path";
20+
import {
21+
computeServerManager,
22+
type ComputeServerManager,
23+
} from "@cocalc/conat/compute/manager";
2024

2125
declare var DEBUG: boolean;
2226

@@ -388,24 +392,34 @@ export class ComputeActions {
388392
}
389393
const course_project_id = store.get("course_project_id");
390394

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.
391400
const courseAssociations =
392401
webapp_client.project_client.computeServers(course_project_id);
393402

394-
const studentAssociations =
395-
webapp_client.project_client.computeServers(target_project_id);
403+
try {
404+
studentAssociations = computeServerManager({
405+
project_id: target_project_id,
406+
});
396407

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+
}
408420
}
421+
} finally {
422+
studentAssociations?.close();
409423
}
410424
};
411425
}

src/packages/util/smc-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/* autogenerated by the update_version script */
2-
exports.version=1757119901;
2+
exports.version=1758034770;

0 commit comments

Comments
 (0)