CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/compute/exclude-from-sync.tsx
Views: 687
1
import type {
2
State,
3
Configuration,
4
} from "@cocalc/util/db-schema/compute-servers";
5
import { Alert, Select, Switch } from "antd";
6
import { CSSProperties, useEffect, useState } from "react";
7
import { Icon } from "@cocalc/frontend/components";
8
import { DEFAULT_FAST_LOCAL } from "./create-compute-server";
9
10
interface Props {
11
setConfig;
12
configuration: Configuration;
13
disabled?: boolean;
14
state?: State;
15
style?: CSSProperties;
16
id?: number;
17
}
18
19
export default function ExcludeFromSync({
20
setConfig,
21
configuration,
22
disabled,
23
state = "deprovisioned",
24
style,
25
id,
26
}: Props) {
27
const [help, setHelp] = useState<boolean>(false);
28
const [value, setValue] = useState<readonly string[] | undefined>(
29
configuration.excludeFromSync,
30
);
31
useEffect(() => {
32
setValue(configuration.excludeFromSync);
33
}, [configuration.excludeFromSync]);
34
35
return (
36
<div style={style}>
37
<div style={{ color: "#666", marginBottom: "5px" }}>
38
<b>
39
<Switch
40
size="small"
41
checkedChildren={"Help"}
42
unCheckedChildren={"Help"}
43
style={{ float: "right" }}
44
checked={help}
45
onChange={(val) => setHelp(val)}
46
/>
47
<Icon name="bolt" /> Fast Local Directories
48
</b>
49
</div>
50
{help && (
51
<Alert
52
showIcon
53
style={{ margin: "15px 0" }}
54
type="info"
55
message={"Fast Local Directories"}
56
description={
57
<div>
58
<p>
59
Files you change or create on the compute server in these
60
directories will not be saved back to the project when you click
61
the Sync button or Save a file. Disk IO in these directories is{" "}
62
<b>
63
<i>VERY fast</i>
64
</b>
65
, and you can use all available compute server disk space (up to
66
many terabytes).
67
</p>
68
<p>
69
The HOME directory of the project is mounted over the network
70
and can be very slow. List top level subdirectories of HOME that
71
you do not want to be syned over the network. Files in these
72
directories are stored in <code>/data</code> on the compute
73
server's disk only, which is extremely fast.
74
<b>
75
Fast local directories are NOT backed up, but do persist until
76
the compute server is deleted or deprovisioned.
77
</b>
78
</p>
79
<p>
80
If you include <code>~</code> or <code>.</code> in the list
81
below, then the sync process is temporarily disabled, though
82
your HOME directory is still mounted over the network.
83
{id == null && (
84
<>
85
The directory <code>{DEFAULT_FAST_LOCAL}</code> is a fast
86
local directory by default. (You can also use
87
<code>[id]</code> in the path, and it will be replaced by
88
the numerical id of the compute server.) You can add and
89
remove any other fast local subdirectories of HOME.
90
</>
91
)}
92
</p>
93
<p>
94
You can efficiently copy files and directories back and forth
95
between your shared HOME directory and a compute server using
96
the File Explorer.
97
</p>
98
</div>
99
}
100
/>
101
)}
102
<div style={{ color: "#666" }}>
103
Fast local directories exist only on the compute server and{" "}
104
<b>are NOT backed up in any way</b>. They persist until the compute
105
server is deleted or deprovisioned.
106
</div>
107
<Select
108
value={value}
109
disabled={
110
disabled ||
111
state == "running" ||
112
state == "suspended" ||
113
state == "suspending"
114
}
115
tokenSeparators={["/", " ", "|"]}
116
mode="tags"
117
style={{ width: "100%", marginTop: "10px" }}
118
placeholder="Type a directory name then hit enter..."
119
onChange={(value) => {
120
setValue(value);
121
setConfig({ excludeFromSync: value ?? [] });
122
}}
123
/>
124
</div>
125
);
126
}
127
128