fix: add cleanup after native update#321
Conversation
Changed Files
|
WalkthroughThis PR implements app version detection and cleanup across Android and iOS platforms. iOS introduces version tracking via UserDefaults with automatic directory cleanup on version changes and event logging. Android retrieves the app version at initialization. Unused iOS imports are removed. ChangesApp Version Tracking and Cleanup
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
b9e4d86 to
20e2ec9
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
airborne_sdk_iOS/hyper-ota/Airborne/AirborneSwift/AJPApplicationManagerUtils.swift (1)
52-58: ⚡ Quick winLog cleanup failures for observability.
Both methods silently ignore failures from
cleanupEntireDirectory. Sincetrackeris available, consider logging cleanup failures to provide visibility when version-change cleanup doesn't complete successfully.📊 Proposed logging enhancement
func cleanupPackageDirectory() { - fileUtil.cleanupEntireDirectory(AJPApplicationConstants.JUSPAY_PACKAGE_DIR) + let success = fileUtil.cleanupEntireDirectory(AJPApplicationConstants.JUSPAY_PACKAGE_DIR) + if !success { + let map = NSMutableDictionary() + map["directory"] = AJPApplicationConstants.JUSPAY_PACKAGE_DIR + tracker.trackError("cleanup_directory_failed", value: map) + } } func cleanupManifestDirectory() { - fileUtil.cleanupEntireDirectory(AJPApplicationConstants.JUSPAY_MANIFEST_DIR) + let success = fileUtil.cleanupEntireDirectory(AJPApplicationConstants.JUSPAY_MANIFEST_DIR) + if !success { + let map = NSMutableDictionary() + map["directory"] = AJPApplicationConstants.JUSPAY_MANIFEST_DIR + tracker.trackError("cleanup_directory_failed", value: map) + } }This assumes
cleanupEntireDirectoryis updated to returnBoolper the previous comment.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@airborne_sdk_iOS/hyper-ota/Airborne/AirborneSwift/AJPApplicationManagerUtils.swift` around lines 52 - 58, Update cleanupPackageDirectory and cleanupManifestDirectory to check the Bool returned by fileUtil.cleanupEntireDirectory(AJPApplicationConstants.JUSPAY_PACKAGE_DIR) and fileUtil.cleanupEntireDirectory(AJPApplicationConstants.JUSPAY_MANIFEST_DIR) respectively, and if the call returns false call the available tracker to record the failure (include which constant/directory and a short context message). Use the exact symbols cleanupPackageDirectory, cleanupManifestDirectory, fileUtil.cleanupEntireDirectory, AJPApplicationConstants.JUSPAY_PACKAGE_DIR, AJPApplicationConstants.JUSPAY_MANIFEST_DIR and the existing tracker instance to log the error so cleanup failures are observable.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@airborne_sdk_iOS/hyper-ota/Airborne/AirborneSwift/AJPApplicationManager.swift`:
- Around line 280-282: The current code in AJPApplicationManager.swift builds
appVersion from Bundle keys majorVersion and minorVersion and will produce "."
if both are empty; update the logic that computes
majorVersion/minorVersion/appVersion to validate and apply sensible fallbacks
(e.g., use "unknown" or trim empty parts) and avoid producing a bare ".";
specifically locate the variables majorVersion, minorVersion and the appVersion
interpolation and change the construction to skip empty segments or substitute a
default token so appVersion is always a meaningful string for cleanup/tracking
logic.
In `@airborne_sdk_iOS/hyper-ota/Airborne/AirborneSwiftCore/AJPFileUtil.swift`:
- Around line 250-266: The cleanupEntireDirectory(_ dirName: String) method
currently swallows errors with try? when calling
FileManager.removeItem(atPath:), so update cleanupEntireDirectory to capture and
report failures: replace the silent try? with a do/catch around
FileManager.default.removeItem(atPath: rootPath), and in the catch forward the
Error to the caller (e.g., add a completion handler (Result<Void, Error>) or an
optional Tracker parameter) and call its logging method with the error and
rootPath; ensure you handle the success path similarly and keep the directory
composition logic in cleanupEntireDirectory unchanged.
In
`@airborne-react-native/android/src/main/java/in/juspay/airborneplugin/Airborne.kt`:
- Around line 63-64: Replace the silent catch in Airborne.kt that currently
swallows exceptions during version retrieval with explicit logging: in the catch
(_: Exception) block, capture the exception (e) and call android.util.Log.e with
a clear message like "Failed to retrieve Airborne version" and the exception,
then return the same fallback (empty string) so HyperOTAServices behavior is
unchanged; add a TAG constant if needed and ensure android.util.Log is imported
so failures are visible in logs for debugging.
---
Nitpick comments:
In
`@airborne_sdk_iOS/hyper-ota/Airborne/AirborneSwift/AJPApplicationManagerUtils.swift`:
- Around line 52-58: Update cleanupPackageDirectory and cleanupManifestDirectory
to check the Bool returned by
fileUtil.cleanupEntireDirectory(AJPApplicationConstants.JUSPAY_PACKAGE_DIR) and
fileUtil.cleanupEntireDirectory(AJPApplicationConstants.JUSPAY_MANIFEST_DIR)
respectively, and if the call returns false call the available tracker to record
the failure (include which constant/directory and a short context message). Use
the exact symbols cleanupPackageDirectory, cleanupManifestDirectory,
fileUtil.cleanupEntireDirectory, AJPApplicationConstants.JUSPAY_PACKAGE_DIR,
AJPApplicationConstants.JUSPAY_MANIFEST_DIR and the existing tracker instance to
log the error so cleanup failures are observable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5c6c0885-898b-457d-93c1-3be83d806636
📒 Files selected for processing (6)
airborne-react-native/android/src/main/java/in/juspay/airborneplugin/Airborne.ktairborne-react-native/ios/AirborneReact.mmairborne_sdk_iOS/hyper-ota/Airborne/AirborneSwift/AJPApplicationManager.swiftairborne_sdk_iOS/hyper-ota/Airborne/AirborneSwift/AJPApplicationManagerUtils.swiftairborne_sdk_iOS/hyper-ota/Airborne/AirborneSwiftCore/AJPFileUtil.swiftairborne_sdk_iOS/hyper-ota/Airborne/AirborneSwiftModel/AJPApplicationConstants.swift
💤 Files with no reviewable changes (1)
- airborne-react-native/ios/AirborneReact.mm
Summary by CodeRabbit