Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/project/sync/listings.ts
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import {6registerListingsTable as registerListingsTable0,7getListingsTable,8} from "@cocalc/sync/listings";9import getListing from "@cocalc/backend/get-listing";10import { Watcher } from "@cocalc/backend/path-watcher";11import { close_all_syncdocs_in_tree } from "./sync-doc";12import { getLogger } from "@cocalc/backend/logger";13import { existsSync } from "fs";1415const logger = getLogger("project:sync:listings");16const log = logger.debug;1718export { getListingsTable };1920export function registerListingsTable(table, query): void {21log("registerListingsTables");22log("registerListingsTables: query=", query);23const onDeletePath = async (path) => {24// Also we need to close *all* syncdocs that are going to be deleted,25// and wait until closing is done before we return.26await close_all_syncdocs_in_tree(path);27};2829const createWatcher = (path: string, debounce: number) =>30new Watcher(path, { debounce });3132const { project_id, compute_server_id } = query.listings[0];3334if (compute_server_id == 0) {35log(36"registerListingsTables -- actually registering since compute_server_id=0",37);38registerListingsTable0({39table,40project_id,41compute_server_id,42onDeletePath,43getListing,44createWatcher,45existsSync,46getLogger,47});48} else {49log(50"registerListingsTables -- NOT implemented since compute_server_id=",51compute_server_id,52);53}54}555657