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
|
-
|
|
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
|
-
|
|
128
|
+
promise.resolve(metadata);
|
|
129
129
|
} else {
|
|
130
|
-
|
|
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
|
-
|
|
167
|
-
|
|
166
|
+
sharedPrefs.putString(VERSION, previousVersion)
|
|
167
|
+
sharedPrefs.putString(PREVIOUS_VERSION, "")
|
|
168
168
|
} else {
|
|
169
|
-
|
|
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 =
|
|
31
|
+
val pathName = pathKey ?: PREVIOUS_PATH
|
|
32
32
|
val sharedPrefs = SharedPrefs(context)
|
|
33
|
-
val
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|