Function
checkFileExists
(
directoryHandle: FileSystemDirectoryHandle,
fileName: string
)
Source from the content-addressed store, hash-verified
| 60 | } |
| 61 | |
| 62 | async function checkFileExists( |
| 63 | directoryHandle: FileSystemDirectoryHandle, |
| 64 | fileName: string |
| 65 | ): Promise<boolean> { |
| 66 | try { |
| 67 | await directoryHandle.getFileHandle(fileName); |
| 68 | return true; |
| 69 | } catch (e) { |
| 70 | if (e instanceof Error && e.name === 'NotFoundError') { |
| 71 | return false; |
| 72 | } |
| 73 | throw e; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | function addSuffixToFile(fileName: string, suffix: number): string { |
| 78 | const dotIndex = fileName.lastIndexOf('.'); |
Tested by
no test coverage detected