(hash: string)
| 57 | * Returns null if not found or on error. |
| 58 | */ |
| 59 | export async function retrievePastedText(hash: string): Promise<string | null> { |
| 60 | try { |
| 61 | const pastePath = getPastePath(hash) |
| 62 | return await readFile(pastePath, { encoding: 'utf8' }) |
| 63 | } catch (error) { |
| 64 | // ENOENT is expected when paste doesn't exist |
| 65 | if (!isENOENT(error)) { |
| 66 | logForDebugging(`Failed to retrieve paste ${hash}: ${error}`) |
| 67 | } |
| 68 | return null |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Clean up old paste files that are no longer referenced. |
no test coverage detected