Commit 8138c569 authored by Rina Sergeeva's avatar Rina Sergeeva

fix archive recignition

parent 2f95850c
......@@ -9,7 +9,6 @@ import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
public class UnzipUtil {
......@@ -53,13 +52,18 @@ public class UnzipUtil {
}
}
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getStackTrace());
}
logger.info("Unzip " + unzipDir + "\n");
return unzipFiles;
}
boolean isZip(File file) {
if(file.isDirectory()){
return false;
}
String extension = file.getName().substring(file.getName().indexOf("."));
return extension.equals(".zip") || extension.equals(".zipx") || extension.equals(".gzip") || extension.equals(".rar");
// int fileSignature = 0;
// try (RandomAccessFile raf = new RandomAccessFile(file, "r")) {
// fileSignature = raf.readInt();
......@@ -68,16 +72,6 @@ public class UnzipUtil {
// // handle if you like
// }
// return fileSignature == 0x504B0304 || fileSignature == 0x504B0506 || fileSignature == 0x504B0708;
try{
ZipFile zipFile = new ZipFile(file);
} catch (ZipException e) {
logger.error(file + " not a zip");
return false;
} catch (IOException e) {
logger.error("IO exception while evaluation isZip()");
return false;
}
return true;
}
private static void write(InputStream inputStream, OutputStream outputStream) throws IOException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment