Skip to content

Conversation

@serhii-londar
Copy link
Collaborator

  • Added locking mechanism to safely read accumulated state (strings, plurals, errors) when no files are available for download.
  • Ensured completion handler returns the correct state without risking data corruption during concurrent access.

…n handling

- Added locking mechanism to safely read accumulated state (strings, plurals, errors) when no files are available for download.
- Ensured completion handler returns the correct state without risking data corruption during concurrent access.
@codecov
Copy link

codecov bot commented Sep 13, 2025

Codecov Report

❌ Patch coverage is 46.15385% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.17%. Comparing base (87517b4) to head (be191c4).

Files with missing lines Patch % Lines
...tionDownloader/CrowdinLocalizationDownloader.swift 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #346      +/-   ##
==========================================
+ Coverage   62.72%   63.17%   +0.45%     
==========================================
  Files         126      126              
  Lines        4839     4851      +12     
==========================================
+ Hits         3035     3064      +29     
+ Misses       1804     1787      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@serhii-londar serhii-londar requested a review from Copilot October 22, 2025 20:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances thread safety in the CrowdinLocalizationDownloader by adding proper locking when reading accumulated state in the no-files-to-download scenario. It also improves test isolation by adding comprehensive state cleanup in test setup.

  • Added lock/unlock mechanism to safely capture strings, plurals, and errors before invoking completion handler
  • Enhanced test setup with global state cleanup to prevent test interference

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Sources/CrowdinSDK/Providers/Crowdin/LocalizationDownloader/CrowdinLocalizationDownloader.swift Added thread-safe state reading with lock mechanism when no files are available for download
Sources/Tests/Core/RealLocalizationProviderTests.swift Added global state cleanup in setUp() and manifestManager.clear() call to improve test isolation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +48 to +52
self.lock.lock()
let strings = self.strings
let plurals = self.plurals
let errors = self.errors
self.lock.unlock()
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lock is not released if an exception occurs between lock() and unlock(). Consider using defer to ensure the lock is always unlocked, even in exceptional cases: self.lock.lock(); defer { self.lock.unlock() }

Copilot uses AI. Check for mistakes.
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