Skip to content

Harden FileSystem init error handling and align file-exists test constants - #36

Closed
VenkataKrishnaGarapati with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-code-for-review-comments
Closed

Harden FileSystem init error handling and align file-exists test constants#36
VenkataKrishnaGarapati with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-code-for-review-comments

Conversation

Copilot AI commented Jun 4, 2026

Copy link
Copy Markdown

This PR addresses the review-thread feedback on FileSystem initialization and its regression coverage. It removes broad error suppression during cache directory setup and aligns tests with the shared file-exists error constants used by production code.

  • Initializer error handling

    • Replaced fail-fast try! directory creation with explicit do/catch handling.
    • Treats only NSError.isFileExistsError as ignorable; other creation failures are surfaced via assertionFailure(...).
    • Keeps directory creation idempotent by using withIntermediateDirectories: true.
  • Targeted regression tests

    • Added FileSystemInitializationTests for:
      • init behavior when createDirectory returns “file exists”
      • repeated init when parent directory already exists
    • Updated the file-exists test double to use NSError.FileErrors.domain and NSError.FileErrors.fileExistsErrorCode (no duplicated raw 516).
do {
    try backingManager.createDirectory(at: self.parentDirectory, withIntermediateDirectories: true, attributes: nil)
} catch {
    if !(error as NSError).isFileExistsError {
        assertionFailure("Failed to create cache directory at \(self.parentDirectory.path): \(error)")
    }
}

@VenkataKrishnaGarapati
VenkataKrishnaGarapati marked this pull request as ready for review June 4, 2026 03:46
Copilot AI changed the title [WIP] Fix code based on review comments Harden FileSystem init error handling and align file-exists test constants Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants