History

feat(connect): keep macOS hosts reachable after reboot

Theo Browne committed 3 months ago

Commit ec3c5f61 parent 90f391312 files · +690 −91Browse files

Showing the changes to apps/server/src/atomicWrite.ts (1 of 12 files). Show all

Unified · Split

apps/server/src/atomicWrite.ts+22−0
@@ -23,3 +23,25 @@ export const writeFileStringAtomically = (input: { · 22 unmodified lines
2323 yield* fs.rename(tempPath, input.filePath);
2424 }),
2525 );
26+
27+export const writeSymbolicLinkAtomically = (input: {
28+ readonly linkPath: string;
29+ readonly targetPath: string;
30+}) =>
31+ Effect.scoped(
32+ Effect.gen(function* () {
33+ const fs = yield* FileSystem.FileSystem;
34+ const path = yield* Path.Path;
35+ const targetDirectory = path.dirname(input.linkPath);
36+
37+ yield* fs.makeDirectory(targetDirectory, { recursive: true });
38+ const tempDirectory = yield* fs.makeTempDirectoryScoped({
39+ directory: targetDirectory,
40+ prefix: `${path.basename(input.linkPath)}.`,
41+ });
42+ const tempPath = path.join(tempDirectory, "link.tmp");
43+
44+ yield* fs.symlink(input.targetPath, tempPath);
45+ yield* fs.rename(tempPath, input.linkPath);
46+ }),
47+ );

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t