--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java Tue Oct 29 13:51:14 2019 -0400
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java Tue Oct 29 14:22:18 2019 -0400
@@ -739,7 +739,20 @@
Files.copy(eSrc.file, u.file, REPLACE_EXISTING);
}
}
+ } else if (eSrc.type == Entry.CEN && eSrc.method != defaultCompressionMethod) {
+
+ /**
+ * We are copying a file within the same Zip file using a
+ * different compression method.
+ */
+ try (InputStream in = newInputStream(src);
+ OutputStream out = newOutputStream(dst,
+ CREATE, TRUNCATE_EXISTING, WRITE)) {
+ in.transferTo(out);
+ }
+ u = getEntry(dst);
}
+
if (!hasCopyAttrs)
u.mtime = u.atime= u.ctime = System.currentTimeMillis();
update(u);
@@ -789,7 +802,8 @@
return os;
}
return getOutputStream(supportPosix ?
- new PosixEntry((PosixEntry)e, Entry.NEW) : new Entry(e, Entry.NEW));
+ new PosixEntry((PosixEntry)e, Entry.NEW, defaultCompressionMethod)
+ : new Entry(e, Entry.NEW, defaultCompressionMethod));
} else {
if (!hasCreate && !hasCreateNew)
throw new NoSuchFileException(getString(path));
@@ -2338,6 +2352,11 @@
this.file = file;
}
+ Entry(Entry e, int type, int compressionMethod) {
+ this(e, type);
+ this.method = compressionMethod;
+ }
+
Entry(Entry e, int type) {
name(e.name);
this.isdir = e.isdir;
@@ -2905,6 +2924,11 @@
super(name, file, type, attrs);
}
+ PosixEntry(PosixEntry e, int type, int compressionMethod) {
+ super(e, type);
+ this.method = compressionMethod;
+ }
+
PosixEntry(PosixEntry e, int type) {
super(e, type);
this.owner = e.owner;