mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 12:16:49 +00:00
[refactor] The 'copy zip files stripping signatures' code cleaned up ever so slightly; timestamps of zip entries is now preserved.
This commit is contained in:
1 file changed
+18
-14
@@ -90,22 +90,14 @@ public class DownloadEclipseDependencies {
|
||||
return;
|
||||
}
|
||||
System.out.print("Downloading '" + filename + "'... ");
|
||||
ZipInputStream in = null;
|
||||
ZipOutputStream out = null;
|
||||
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
in = new ZipInputStream(getStreamForUrl(repositoryUrl + filename));
|
||||
out = new ZipOutputStream(new FileOutputStream(targetFile));
|
||||
in = getStreamForUrl(repositoryUrl + filename);
|
||||
out = new FileOutputStream(targetFile);
|
||||
|
||||
ZipEntry zipEntry;
|
||||
while ((zipEntry = in.getNextEntry()) != null) {
|
||||
String name = zipEntry.getName();
|
||||
|
||||
// Remove signature files
|
||||
if (name.matches("META-INF/.*\\.(SF|RSA)")) continue;
|
||||
|
||||
out.putNextEntry(new ZipEntry(name));
|
||||
copy(in, out);
|
||||
}
|
||||
copyZipButStripSignatures(in, out);
|
||||
System.out.println("[done]");
|
||||
} catch (IOException e) {
|
||||
System.out.println("[error]");
|
||||
@@ -118,6 +110,18 @@ public class DownloadEclipseDependencies {
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyZipButStripSignatures(InputStream rawIn, OutputStream rawOut) throws IOException {
|
||||
ZipInputStream in = new ZipInputStream(rawIn);
|
||||
ZipOutputStream out = new ZipOutputStream(rawOut);
|
||||
|
||||
ZipEntry zipEntry;
|
||||
while ((zipEntry = in.getNextEntry()) != null) {
|
||||
if (zipEntry.getName().matches("META-INF/.*\\.(SF|RSA)")) continue;
|
||||
out.putNextEntry(zipEntry);
|
||||
copy(in, out);
|
||||
}
|
||||
}
|
||||
|
||||
private static void copy(InputStream from, OutputStream to) throws IOException {
|
||||
byte[] b = new byte[4096];
|
||||
while (true) {
|
||||
|
||||
Reference in new issue
Block a user