react-native-ota-hot-update 2.2.52 → 2.2.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -113,7 +113,7 @@ class OtaHotUpdateModule internal constructor(context: ReactApplicationContext)
113
113
 
114
114
  val currentVersion = sharedPrefs.getString(VERSION)
115
115
  if (currentVersion != "" && currentVersion != version) {
116
- sharedPrefs.putString(PREVIOUS_VERSION, currentVersion)
116
+ sharedPrefs.putString(PREVIOUS_VERSION, currentVersion)
117
117
  }
118
118
 
119
119
  sharedPrefs.putString(VERSION, version)
@@ -125,9 +125,9 @@ class OtaHotUpdateModule internal constructor(context: ReactApplicationContext)
125
125
  val sharedPrefs = SharedPrefs(reactApplicationContext)
126
126
  val metadata = sharedPrefs.getString(METADATA)
127
127
  if (metadata != "") {
128
- promise.resolve(metadata);
128
+ promise.resolve(metadata);
129
129
  } else {
130
- promise.resolve(null);
130
+ promise.resolve(null);
131
131
  }
132
132
  }
133
133
 
@@ -163,10 +163,10 @@ class OtaHotUpdateModule internal constructor(context: ReactApplicationContext)
163
163
  sharedPrefs.putString(PREVIOUS_PATH, "")
164
164
 
165
165
  if (previousVersion != "") {
166
- sharedPrefs.putString(VERSION, previousVersion)
167
- sharedPrefs.putString(PREVIOUS_VERSION, "")
166
+ sharedPrefs.putString(VERSION, previousVersion)
167
+ sharedPrefs.putString(PREVIOUS_VERSION, "")
168
168
  } else {
169
- sharedPrefs.putString(VERSION, "")
169
+ sharedPrefs.putString(VERSION, "")
170
170
  }
171
171
 
172
172
  promise.resolve(true)
@@ -28,15 +28,19 @@ class Utils internal constructor(private val context: Context) {
28
28
  return directory.delete()
29
29
  }
30
30
  fun deleteOldBundleIfneeded(pathKey: String?): Boolean {
31
- val pathName = if (pathKey != null) pathKey else PREVIOUS_PATH
31
+ val pathName = pathKey ?: PREVIOUS_PATH
32
32
  val sharedPrefs = SharedPrefs(context)
33
- val path = sharedPrefs.getString(pathName)
34
- if (!path.isNullOrEmpty()) {
35
- val file = File(path)
36
- if (file.exists() && file.isFile) {
37
- val isDeleted = deleteDirectory(file.parentFile)
38
- sharedPrefs.putString(pathName, "")
39
- return isDeleted
33
+ val bundlePath = sharedPrefs.getString(pathName)
34
+
35
+ if (!bundlePath.isNullOrEmpty()) {
36
+ val bundleFile = File(bundlePath)
37
+ if (bundleFile.exists() && bundleFile.isFile) {
38
+ val outputFolder = bundleFile.parentFile
39
+ if (outputFolder != null && outputFolder.exists() && outputFolder.isDirectory) {
40
+ val isDeleted = deleteDirectory(outputFolder)
41
+ sharedPrefs.putString(pathName, "")
42
+ return isDeleted
43
+ }
40
44
  }
41
45
  }
42
46
  return false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ota-hot-update",
3
- "version": "2.2.52",
3
+ "version": "2.2.61",
4
4
  "description": "Hot update for react native",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",