mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-11 08:04:23 +08:00
fix getCurrentPackage
This commit is contained in:
@@ -411,6 +411,10 @@ public class CodePush {
|
||||
@Override
|
||||
protected Void doInBackground(Object... params) {
|
||||
WritableMap currentPackage = codePushPackage.getCurrentPackage();
|
||||
if (currentPackage == null) {
|
||||
promise.resolve("");
|
||||
return null;
|
||||
}
|
||||
|
||||
Boolean isPendingUpdate = false;
|
||||
|
||||
|
||||
@@ -129,14 +129,14 @@ public class CodePushPackage {
|
||||
public WritableMap getCurrentPackage() {
|
||||
String folderPath = getCurrentPackageFolderPath();
|
||||
if (folderPath == null) {
|
||||
return new WritableNativeMap();
|
||||
return null;
|
||||
}
|
||||
|
||||
String packagePath = CodePushUtils.appendPathComponent(folderPath, PACKAGE_FILE_NAME);
|
||||
try {
|
||||
return CodePushUtils.getWritableMapFromFile(packagePath);
|
||||
} catch (IOException e) {
|
||||
// There is no current package.
|
||||
// Should not happen unless the update metadata was somehow deleted.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -155,6 +155,12 @@ public class CodePushPackage {
|
||||
DownloadProgressCallback progressCallback) throws IOException {
|
||||
|
||||
String newPackageFolderPath = getPackageFolderPath(CodePushUtils.tryGetString(updatePackage, PACKAGE_HASH_KEY));
|
||||
if (FileUtils.fileAtPathExists(newPackageFolderPath)) {
|
||||
// This removes any stale data in newPackageFolderPath that could have been left
|
||||
// uncleared due to a crash or error during the download or install process.
|
||||
FileUtils.deleteDirectoryAtPath(newPackageFolderPath);
|
||||
}
|
||||
|
||||
String downloadUrlString = CodePushUtils.tryGetString(updatePackage, DOWNLOAD_URL_KEY);
|
||||
URL downloadUrl = null;
|
||||
HttpURLConnection connection = null;
|
||||
|
||||
Reference in New Issue
Block a user