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/frontend/compute/exclude-from-sync.tsx
Views: 687
import type {1State,2Configuration,3} from "@cocalc/util/db-schema/compute-servers";4import { Alert, Select, Switch } from "antd";5import { CSSProperties, useEffect, useState } from "react";6import { Icon } from "@cocalc/frontend/components";7import { DEFAULT_FAST_LOCAL } from "./create-compute-server";89interface Props {10setConfig;11configuration: Configuration;12disabled?: boolean;13state?: State;14style?: CSSProperties;15id?: number;16}1718export default function ExcludeFromSync({19setConfig,20configuration,21disabled,22state = "deprovisioned",23style,24id,25}: Props) {26const [help, setHelp] = useState<boolean>(false);27const [value, setValue] = useState<readonly string[] | undefined>(28configuration.excludeFromSync,29);30useEffect(() => {31setValue(configuration.excludeFromSync);32}, [configuration.excludeFromSync]);3334return (35<div style={style}>36<div style={{ color: "#666", marginBottom: "5px" }}>37<b>38<Switch39size="small"40checkedChildren={"Help"}41unCheckedChildren={"Help"}42style={{ float: "right" }}43checked={help}44onChange={(val) => setHelp(val)}45/>46<Icon name="bolt" /> Fast Local Directories47</b>48</div>49{help && (50<Alert51showIcon52style={{ margin: "15px 0" }}53type="info"54message={"Fast Local Directories"}55description={56<div>57<p>58Files you change or create on the compute server in these59directories will not be saved back to the project when you click60the Sync button or Save a file. Disk IO in these directories is{" "}61<b>62<i>VERY fast</i>63</b>64, and you can use all available compute server disk space (up to65many terabytes).66</p>67<p>68The HOME directory of the project is mounted over the network69and can be very slow. List top level subdirectories of HOME that70you do not want to be syned over the network. Files in these71directories are stored in <code>/data</code> on the compute72server's disk only, which is extremely fast.73<b>74Fast local directories are NOT backed up, but do persist until75the compute server is deleted or deprovisioned.76</b>77</p>78<p>79If you include <code>~</code> or <code>.</code> in the list80below, then the sync process is temporarily disabled, though81your HOME directory is still mounted over the network.82{id == null && (83<>84The directory <code>{DEFAULT_FAST_LOCAL}</code> is a fast85local directory by default. (You can also use86<code>[id]</code> in the path, and it will be replaced by87the numerical id of the compute server.) You can add and88remove any other fast local subdirectories of HOME.89</>90)}91</p>92<p>93You can efficiently copy files and directories back and forth94between your shared HOME directory and a compute server using95the File Explorer.96</p>97</div>98}99/>100)}101<div style={{ color: "#666" }}>102Fast local directories exist only on the compute server and{" "}103<b>are NOT backed up in any way</b>. They persist until the compute104server is deleted or deprovisioned.105</div>106<Select107value={value}108disabled={109disabled ||110state == "running" ||111state == "suspended" ||112state == "suspending"113}114tokenSeparators={["/", " ", "|"]}115mode="tags"116style={{ width: "100%", marginTop: "10px" }}117placeholder="Type a directory name then hit enter..."118onChange={(value) => {119setValue(value);120setConfig({ excludeFromSync: value ?? [] });121}}122/>123</div>124);125}126127128