update judge logic for v2#513
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR updates the judge logic for v2 in the DownloadTask by separating the resource copying functionality into version-specific methods and implementing proper logic to determine which version to use.
- Separates the
copyFromResourcemethod into v1 and v2 variants with distinct functionality - Adds logic to detect v2 format based on the presence of
copiesv2keys - Reorganizes the copies processing to handle v1 and v2 formats in separate code paths
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| 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; |
There was a problem hiding this comment.
Use primitive boolean instead of wrapper Boolean for simple flag variables. This avoids unnecessary object allocation and potential null pointer issues.
| Boolean isV2 = false; | |
| boolean isV2 = false; |
| if (from.isEmpty()) { | ||
| from = to; | ||
| Iterator<?> keysV2 = copiesv2.keys(); | ||
| if(keysV2.hasNext()){ |
There was a problem hiding this comment.
[nitpick] Missing space after if keyword. Consider using if (keysV2.hasNext()) for consistent code formatting.
| if(keysV2.hasNext()){ | |
| if (keysV2.hasNext()) { |
| String canonicalPath = toFile.getCanonicalPath(); | ||
| if (!canonicalPath.startsWith(param.unzipDirectory.getCanonicalPath() + File.separator)) { | ||
| throw new SecurityException("Illegal name: " + to); | ||
| }else{ |
There was a problem hiding this comment.
[nitpick] Missing space before opening brace. Consider using } else { for consistent code formatting.
| }else{ | |
| } else { |
| if(isV2){ | ||
| copyFromResourceV2(copiesv2List); | ||
| }else{ |
There was a problem hiding this comment.
[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 { |
No description provided.