Function
rollback
(
written: string[],
pending: Map<string, PendingEntry>,
fs: FileSystemAdapter,
resolve: (filePath: string) => string,
)
Source from the content-addressed store, hash-verified
| 93 | } |
| 94 | |
| 95 | async function rollback( |
| 96 | written: string[], |
| 97 | pending: Map<string, PendingEntry>, |
| 98 | fs: FileSystemAdapter, |
| 99 | resolve: (filePath: string) => string, |
| 100 | ): Promise<void> { |
| 101 | await Promise.allSettled( |
| 102 | written.map(async filePath => { |
| 103 | const entry = pending.get(filePath); |
| 104 | if (!entry) { |
| 105 | return; |
| 106 | } |
| 107 | const absolutePath = resolve(filePath); |
| 108 | if (entry.original == null) { |
| 109 | await fs.unlink(absolutePath); |
| 110 | return; |
| 111 | } |
| 112 | await fs.writeFile(absolutePath, entry.original); |
| 113 | }), |
| 114 | ); |
| 115 | } |
Tested by
no test coverage detected