-
Notifications
You must be signed in to change notification settings - Fork 273
update judge logic for v2 #513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -252,19 +252,41 @@ private void doFullPatch(DownloadTaskParams param) throws IOException { | |||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private void copyFromResource(HashMap<String, ArrayList<File> > resToCopy, HashMap<String, ArrayList<File>> resToCopy2) throws IOException { | ||||||||||||||
| private void copyFromResource(HashMap<String, ArrayList<File> > resToCopy) throws IOException { | ||||||||||||||
| SafeZipFile zipFile = new SafeZipFile(new File(context.getPackageResourcePath())); | ||||||||||||||
| Enumeration<? extends ZipEntry> entries = zipFile.entries(); | ||||||||||||||
| while (entries.hasMoreElements()) { | ||||||||||||||
| ZipEntry ze = entries.nextElement(); | ||||||||||||||
|
|
||||||||||||||
| String fn = ze.getName(); | ||||||||||||||
| ArrayList<File> targets = resToCopy.get(fn); | ||||||||||||||
| if (targets != null) { | ||||||||||||||
| File lastTarget = null; | ||||||||||||||
| for (File target: targets) { | ||||||||||||||
| if (UpdateContext.DEBUG) { | ||||||||||||||
| Log.d("react-native-update", "Copying from resource " + fn + " to " + target); | ||||||||||||||
| } | ||||||||||||||
| if (lastTarget != null) { | ||||||||||||||
| copyFile(lastTarget, target); | ||||||||||||||
| } else { | ||||||||||||||
| zipFile.unzipToFile(ze, target); | ||||||||||||||
| lastTarget = target; | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| zipFile.close(); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private void copyFromResourceV2(HashMap<String, ArrayList<File>> resToCopy2) throws IOException { | ||||||||||||||
| SafeZipFile zipFile = new SafeZipFile(new File(context.getPackageResourcePath())); | ||||||||||||||
| Enumeration<? extends ZipEntry> entries = zipFile.entries(); | ||||||||||||||
| while (entries.hasMoreElements()) { | ||||||||||||||
| ZipEntry ze = entries.nextElement(); | ||||||||||||||
| String fn = ze.getName(); | ||||||||||||||
| long zipCrc32 = ze.getCrc(); | ||||||||||||||
| String crc32Decimal = getCRC32AsDecimal(zipCrc32); | ||||||||||||||
| ArrayList<File> targets = resToCopy2.get(crc32Decimal); | ||||||||||||||
| if(targets==null || targets.isEmpty()){ | ||||||||||||||
| targets = resToCopy.get(fn); | ||||||||||||||
| } | ||||||||||||||
| if (targets != null) { | ||||||||||||||
| File lastTarget = null; | ||||||||||||||
| for (File target: targets) { | ||||||||||||||
|
|
@@ -290,6 +312,7 @@ private void doPatchFromApk(DownloadTaskParams param) throws IOException, JSONEx | |||||||||||||
| param.unzipDirectory.mkdirs(); | ||||||||||||||
| HashMap<String, ArrayList<File>> copyList = new HashMap<String, ArrayList<File>>(); | ||||||||||||||
| HashMap<String, ArrayList<File>> copiesv2List = new HashMap<String, ArrayList<File>>(); | ||||||||||||||
| Boolean isV2 = false; | ||||||||||||||
|
|
||||||||||||||
| boolean foundDiff = false; | ||||||||||||||
| boolean foundBundlePatch = false; | ||||||||||||||
|
|
@@ -310,53 +333,56 @@ private void doPatchFromApk(DownloadTaskParams param) throws IOException, JSONEx | |||||||||||||
| JSONObject copies = obj.getJSONObject("copies"); | ||||||||||||||
| JSONObject copiesv2 = obj.getJSONObject("copiesv2"); | ||||||||||||||
| Iterator<?> keys = copies.keys(); | ||||||||||||||
| Iterator<?> keys2 = copiesv2.keys(); | ||||||||||||||
| while( keys.hasNext() ) { | ||||||||||||||
| String to = (String)keys.next(); | ||||||||||||||
| String from = copies.getString(to); | ||||||||||||||
| if (from.isEmpty()) { | ||||||||||||||
| from = to; | ||||||||||||||
| Iterator<?> keysV2 = copiesv2.keys(); | ||||||||||||||
| if(keysV2.hasNext()){ | ||||||||||||||
|
||||||||||||||
| if(keysV2.hasNext()){ | |
| if (keysV2.hasNext()) { |
Copilot
AI
Sep 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Missing space before opening brace. Consider using } else { for consistent code formatting.
| }else{ | |
| } else { |
Copilot
AI
Sep 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Missing spaces around if and else keywords. Consider using if (isV2) { and } else { for consistent code formatting.
| if(isV2){ | |
| copyFromResourceV2(copiesv2List); | |
| }else{ | |
| if (isV2) { | |
| copyFromResourceV2(copiesv2List); | |
| } else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use primitive
booleaninstead of wrapperBooleanfor simple flag variables. This avoids unnecessary object allocation and potential null pointer issues.