mirror of
				https://gitcode.com/gh_mirrors/re/react-native-pushy.git
				synced 2025-10-31 21:33:12 +08:00 
			
		
		
		
	Check diff and patch existence
This commit is contained in:
		| @@ -307,6 +307,8 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> { | |||||||
|         ZipEntry ze; |         ZipEntry ze; | ||||||
|         int count; |         int count; | ||||||
|         String filename; |         String filename; | ||||||
|  |         boolean foundDiff = false; | ||||||
|  |         boolean foundBundlePatch = false; | ||||||
|  |  | ||||||
|         removeDirectory(param.unzipDirectory); |         removeDirectory(param.unzipDirectory); | ||||||
|         param.unzipDirectory.mkdirs(); |         param.unzipDirectory.mkdirs(); | ||||||
| @@ -318,6 +320,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> { | |||||||
|             String fn = ze.getName(); |             String fn = ze.getName(); | ||||||
|  |  | ||||||
|             if (fn.equals("__diff.json")) { |             if (fn.equals("__diff.json")) { | ||||||
|  |                 foundDiff = true; | ||||||
|                 // copy files from assets |                 // copy files from assets | ||||||
|                 byte[] bytes = readBytes(zis); |                 byte[] bytes = readBytes(zis); | ||||||
|                 String json = new String(bytes, "UTF-8"); |                 String json = new String(bytes, "UTF-8"); | ||||||
| @@ -344,6 +347,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> { | |||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
|             if (fn.equals("index.bundlejs.patch")) { |             if (fn.equals("index.bundlejs.patch")) { | ||||||
|  |                 foundBundlePatch = true; | ||||||
|                 // do bsdiff patch |                 // do bsdiff patch | ||||||
|                 byte[] patched = bsdiffPatch(readOriginBundle(), readBytes(zis)); |                 byte[] patched = bsdiffPatch(readOriginBundle(), readBytes(zis)); | ||||||
|  |  | ||||||
| @@ -367,6 +371,12 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         zis.close(); |         zis.close(); | ||||||
|  |         if (!foundDiff) { | ||||||
|  |             throw new Error("diff.json not found"); | ||||||
|  |         } | ||||||
|  |         if (!foundBundlePatch) { | ||||||
|  |             throw new Error("bundle patch not found"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         copyFromResource(copyList); |         copyFromResource(copyList); | ||||||
|  |  | ||||||
| @@ -383,6 +393,8 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> { | |||||||
|         ZipEntry ze; |         ZipEntry ze; | ||||||
|         int count; |         int count; | ||||||
|         String filename; |         String filename; | ||||||
|  |         boolean foundDiff = false; | ||||||
|  |         boolean foundBundlePatch = false; | ||||||
|  |  | ||||||
|         removeDirectory(param.unzipDirectory); |         removeDirectory(param.unzipDirectory); | ||||||
|         param.unzipDirectory.mkdirs(); |         param.unzipDirectory.mkdirs(); | ||||||
| @@ -392,6 +404,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> { | |||||||
|             String fn = ze.getName(); |             String fn = ze.getName(); | ||||||
|  |  | ||||||
|             if (fn.equals("__diff.json")) { |             if (fn.equals("__diff.json")) { | ||||||
|  |                 foundDiff = true; | ||||||
|                 // copy files from assets |                 // copy files from assets | ||||||
|                 byte[] bytes = readBytes(zis); |                 byte[] bytes = readBytes(zis); | ||||||
|                 String json = new String(bytes, "UTF-8"); |                 String json = new String(bytes, "UTF-8"); | ||||||
| @@ -412,6 +425,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> { | |||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
|             if (fn.equals("index.bundlejs.patch")) { |             if (fn.equals("index.bundlejs.patch")) { | ||||||
|  |                 foundBundlePatch = true; | ||||||
|                 // do bsdiff patch |                 // do bsdiff patch | ||||||
|                 byte[] patched = bsdiffPatch(readFile(new File(param.originDirectory, "index.bundlejs")), readBytes(zis)); |                 byte[] patched = bsdiffPatch(readFile(new File(param.originDirectory, "index.bundlejs")), readBytes(zis)); | ||||||
|  |  | ||||||
| @@ -436,6 +450,12 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> { | |||||||
|  |  | ||||||
|         zis.close(); |         zis.close(); | ||||||
|  |  | ||||||
|  |         if (!foundDiff) { | ||||||
|  |             throw new Error("diff.json not found"); | ||||||
|  |         } | ||||||
|  |         if (!foundBundlePatch) { | ||||||
|  |             throw new Error("bundle patch not found"); | ||||||
|  |         } | ||||||
|         if (UpdateContext.DEBUG) { |         if (UpdateContext.DEBUG) { | ||||||
|             Log.d("RNUpdate", "Unzip finished"); |             Log.d("RNUpdate", "Unzip finished"); | ||||||
|         } |         } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 sunnylqm
					sunnylqm