Skip to content

fix: add cleanup after native update#321

Merged
balaganesh-juspay merged 1 commit into
mainfrom
add-cleanup
May 23, 2026
Merged

fix: add cleanup after native update#321
balaganesh-juspay merged 1 commit into
mainfrom
add-cleanup

Conversation

@Yash02Rajput
Copy link
Copy Markdown
Contributor

@Yash02Rajput Yash02Rajput commented May 22, 2026

Summary by CodeRabbit

  • New Features
    • App version is now dynamically detected at runtime on both Android and iOS platforms
    • Automatic cleanup of cached data and package directories is triggered when the app version changes
    • Version change events are logged for diagnostic and tracking purposes

Review Change Stack

@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented May 22, 2026

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Walkthrough

This 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.

Changes

App Version Tracking and Cleanup

Layer / File(s) Summary
iOS version persistence and file cleanup infrastructure
airborne_sdk_iOS/.../AJPApplicationConstants.swift, airborne_sdk_iOS/.../AJPFileUtil.swift
APP_VERSION_USER_DEFAULTS_KEY constant and cleanupEntireDirectory(_:) method provide the foundation for version persistence and directory cleanup operations.
iOS version change detection and directory cleanup
airborne_sdk_iOS/.../AJPApplicationManagerUtils.swift, airborne_sdk_iOS/.../AJPApplicationManager.swift
Manager initialization detects version changes by comparing bundle version against stored UserDefaults value, invokes directory cleanup helpers for manifest and package folders, logs tracking events, and persists the updated version.
Android version retrieval at initialization
airborne-react-native/android/src/main/java/in/juspay/airborneplugin/Airborne.kt
Imports PackageManager and Build; resolves app version from PackageInfo using API-level-aware calls during HyperOTAServices construction, with fallback to empty string on failure.
iOS import cleanup
airborne-react-native/ios/AirborneReact.mm
Removes unused direct imports of AJPLoggerDelegate.h and AJPApplicationManager.h now accessible via Airborne-Swift.h.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A version whispers through the air,
iOS cleans the caches there,
Android counts what bundles bear,
Fresh starts and cleanup, everywhere!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding cleanup logic after native updates, which is reflected across all modified files (Android version detection, iOS version comparison and cleanup triggers).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-cleanup

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Yash02Rajput Yash02Rajput force-pushed the add-cleanup branch 2 times, most recently from b9e4d86 to 20e2ec9 Compare May 22, 2026 13:26
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
airborne_sdk_iOS/hyper-ota/Airborne/AirborneSwift/AJPApplicationManagerUtils.swift (1)

52-58: ⚡ Quick win

Log cleanup failures for observability.

Both methods silently ignore failures from cleanupEntireDirectory. Since tracker is 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 cleanupEntireDirectory is updated to return Bool per 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

📥 Commits

Reviewing files that changed from the base of the PR and between ed77681 and a19eeb7.

📒 Files selected for processing (6)
  • airborne-react-native/android/src/main/java/in/juspay/airborneplugin/Airborne.kt
  • airborne-react-native/ios/AirborneReact.mm
  • airborne_sdk_iOS/hyper-ota/Airborne/AirborneSwift/AJPApplicationManager.swift
  • airborne_sdk_iOS/hyper-ota/Airborne/AirborneSwift/AJPApplicationManagerUtils.swift
  • airborne_sdk_iOS/hyper-ota/Airborne/AirborneSwiftCore/AJPFileUtil.swift
  • airborne_sdk_iOS/hyper-ota/Airborne/AirborneSwiftModel/AJPApplicationConstants.swift
💤 Files with no reviewable changes (1)
  • airborne-react-native/ios/AirborneReact.mm

@balaganesh-juspay balaganesh-juspay merged commit 9ec317b into main May 23, 2026
13 of 14 checks passed
@balaganesh-juspay balaganesh-juspay deleted the add-cleanup branch May 23, 2026 09:06
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