Skip to content

refactor: move disk I/O outside queue.sync in notifySuccess and skip redundant write on 304#376

Closed
Copilot wants to merge 2 commits intolanguages-apifrom
copilot/sub-pr-373
Closed

refactor: move disk I/O outside queue.sync in notifySuccess and skip redundant write on 304#376
Copilot wants to merge 2 commits intolanguages-apifrom
copilot/sub-pr-373

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 22, 2026

In notifySuccess, the 304 Not Modified path read from disk inside queue.sync, blocking the serial queue with file I/O — contradicting the existing comment on the save path. Additionally, the data read from disk was immediately written back to the same file unnecessarily.

Changes

  • Extract loadLanguagesFromDisk(): disk read now happens outside queue.sync, consistent with how writes are handled
  • Skip redundant write on 304: saveSupportedLanguages is only called when fresh data arrived from the network (languages != nil); data already on disk doesn't need to be re-written
// Before: file I/O blocking the queue, then re-writing same data to disk
let (languagesToSave, callbacks) = queue.sync {
    } else if self._supportedLanguages == nil {
        let cachedData = try? Data(contentsOf: URL(fileURLWithPath: self.filePath)) // ❌ blocking I/O inside queue
        ...
    }
}
saveSupportedLanguages(languages: languagesToSave) // ❌ re-writes data just read from disk on 304

// After: read outside queue, skip write on 304
let needsDiskLoad: Bool = languages == nil && queue.sync { _supportedLanguages == nil }
let diskLanguages = needsDiskLoad ? loadLanguagesFromDisk() : nil // ✅ outside queue
...
if languages != nil {
    saveSupportedLanguages(languages: languagesToSave) // ✅ only on 200
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…redundant write on 304

Co-authored-by: serhii-londar <15808174+serhii-londar@users.noreply.github.com>
Copilot AI changed the title [WIP] Update CocoaPods project references and UI adjustments refactor: move disk I/O outside queue.sync in notifySuccess and skip redundant write on 304 Feb 22, 2026
Copilot AI requested a review from serhii-londar February 22, 2026 15:44
@serhii-londar serhii-londar deleted the copilot/sub-pr-373 branch February 22, 2026 16:10
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