( taskId: string, targetPath: string, )
| 427 | * Tries to create the symlink first; if a file already exists, removes it and retries. |
| 428 | */ |
| 429 | export function initTaskOutputAsSymlink( |
| 430 | taskId: string, |
| 431 | targetPath: string, |
| 432 | ): Promise<string> { |
| 433 | return track( |
| 434 | (async () => { |
| 435 | try { |
| 436 | await ensureOutputDir() |
| 437 | const outputPath = getTaskOutputPath(taskId) |
| 438 | |
| 439 | try { |
| 440 | await symlink(targetPath, outputPath) |
| 441 | } catch { |
| 442 | await unlink(outputPath) |
| 443 | await symlink(targetPath, outputPath) |
| 444 | } |
| 445 | |
| 446 | return outputPath |
| 447 | } catch (error) { |
| 448 | logError(error) |
| 449 | return initTaskOutput(taskId) |
| 450 | } |
| 451 | })(), |
| 452 | ) |
| 453 | } |
no test coverage detected