( state: FileHistoryState, messageId: UUID, )
| 494 | * callers that display insertions/deletions. |
| 495 | */ |
| 496 | export async function fileHistoryHasAnyChanges( |
| 497 | state: FileHistoryState, |
| 498 | messageId: UUID, |
| 499 | ): Promise<boolean> { |
| 500 | if (!fileHistoryEnabled()) { |
| 501 | return false |
| 502 | } |
| 503 | |
| 504 | const targetSnapshot = state.snapshots.findLast( |
| 505 | snapshot => snapshot.messageId === messageId, |
| 506 | ) |
| 507 | if (!targetSnapshot) { |
| 508 | return false |
| 509 | } |
| 510 | |
| 511 | for (const trackingPath of state.trackedFiles) { |
| 512 | try { |
| 513 | const filePath = maybeExpandFilePath(trackingPath) |
| 514 | const targetBackup = targetSnapshot.trackedFileBackups[trackingPath] |
| 515 | const backupFileName: BackupFileName | undefined = targetBackup |
| 516 | ? targetBackup.backupFileName |
| 517 | : getBackupFileNameFirstVersion(trackingPath, state) |
| 518 | |
| 519 | if (backupFileName === undefined) { |
| 520 | continue |
| 521 | } |
| 522 | if (backupFileName === null) { |
| 523 | // Backup says file did not exist; probe via stat (operate-then-catch). |
| 524 | if (await pathExists(filePath)) return true |
| 525 | continue |
| 526 | } |
| 527 | if (await checkOriginFileChanged(filePath, backupFileName)) return true |
| 528 | } catch (error) { |
| 529 | logError(error) |
| 530 | } |
| 531 | } |
| 532 | return false |
| 533 | } |
| 534 | |
| 535 | /** |
| 536 | * Applies the given file snapshot state to the tracked files (writes/deletes |
no test coverage detected