|
15 | 15 | import java.util.*;
|
16 | 16 |
|
17 | 17 | import java.nio.file.Files;
|
| 18 | +import java.nio.file.Paths; |
18 | 19 | import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
19 | 20 | import java.util.logging.Level;
|
20 | 21 | import java.util.logging.Logger;
|
@@ -695,33 +696,42 @@ private boolean examineZipfile(FileInputStream zip_file_stream){
|
695 | 696 | this.filesListInDir.clear();
|
696 | 697 | this.filesizeHash.clear();
|
697 | 698 | this.fileGroups.clear();
|
698 |
| - |
699 |
| - try{ |
| 699 | + |
| 700 | + try{ |
700 | 701 | ZipInputStream zipStream = new ZipInputStream(zip_file_stream);
|
701 | 702 | ZipEntry entry;
|
702 |
| - |
| 703 | + List<String> hiddenDirectories = new ArrayList<>(); |
703 | 704 | while((entry = zipStream.getNextEntry())!=null){
|
| 705 | + String zentryFileName = entry.getName(); |
| 706 | + boolean isDirectory = entry.isDirectory(); |
| 707 | + |
| 708 | + Boolean skip = isDirectory || this.isFileToSkip(zentryFileName); |
| 709 | + |
| 710 | + // check if path is hidden |
| 711 | + if (isDirectory && Files.isHidden(Paths.get(zentryFileName))) { |
| 712 | + hiddenDirectories.add(zentryFileName); |
| 713 | + logger.fine("Ignoring files under hidden directory: " + zentryFileName); |
| 714 | + } else { |
| 715 | + // check if the path was already found to be hidden |
| 716 | + for (String hidden : hiddenDirectories) { |
| 717 | + if (zentryFileName.startsWith(hidden)) { |
| 718 | + skip = true; |
| 719 | + break; |
| 720 | + } |
| 721 | + } |
| 722 | + } |
704 | 723 |
|
705 |
| - String zentryFileName = entry.getName(); |
706 |
| - //msg("zip entry: " + entry.getName()); |
707 |
| - // Skip files or folders starting with __ |
708 |
| - if (this.isFileToSkip(zentryFileName)){ |
709 |
| - continue; |
710 |
| - } |
711 |
| - |
712 |
| - if (entry.isDirectory()) { |
713 |
| - //String dirpath = outputFolder + "/" + zentryFileName; |
714 |
| - //createDirectory(dirpath); |
715 |
| - continue; |
| 724 | + if (skip) { |
| 725 | + continue; |
716 | 726 | }
|
717 |
| - |
| 727 | + |
718 | 728 | String unzipFileName = this.getFileBasename(zentryFileName);
|
719 | 729 | if (unzipFileName==null){
|
720 | 730 | logger.warning("Zip Entry Basename is an empty string: " + zentryFileName);
|
721 | 731 | continue;
|
722 | 732 | }
|
723 | 733 | String unzipFolderName = this.getFolderName(zentryFileName);
|
724 |
| - |
| 734 | + |
725 | 735 | String unzipFilePath = unzipFileName;
|
726 | 736 | if (unzipFolderName != null) {
|
727 | 737 | unzipFilePath = unzipFolderName + "/" + unzipFileName;
|
|
0 commit comments