提交 090bbd05 编写于 作者: S sherman

8002390: (zipfs) Problems moving files between zip file systems

Summary: fixed the corner cases in zipfs
Reviewed-by: sherman
Contributed-by: mark.sheppard@oracle.com
上级 bb0bb6cf
...@@ -466,7 +466,10 @@ public class ZipFileSystem extends FileSystem { ...@@ -466,7 +466,10 @@ public class ZipFileSystem extends FileSystem {
if (eSrc.type == Entry.NEW || eSrc.type == Entry.FILECH) if (eSrc.type == Entry.NEW || eSrc.type == Entry.FILECH)
{ {
u.type = eSrc.type; // make it the same type u.type = eSrc.type; // make it the same type
if (!deletesrc) { // if it's not "rename", just take the data if (deletesrc) { // if it's a "rename", take the data
u.bytes = eSrc.bytes;
u.file = eSrc.file;
} else { // if it's not "rename", copy the data
if (eSrc.bytes != null) if (eSrc.bytes != null)
u.bytes = Arrays.copyOf(eSrc.bytes, eSrc.bytes.length); u.bytes = Arrays.copyOf(eSrc.bytes, eSrc.bytes.length);
else if (eSrc.file != null) { else if (eSrc.file != null) {
...@@ -1118,7 +1121,7 @@ public class ZipFileSystem extends FileSystem { ...@@ -1118,7 +1121,7 @@ public class ZipFileSystem extends FileSystem {
if (old != null) { if (old != null) {
removeFromTree(old); removeFromTree(old);
} }
if (e.type == Entry.NEW || e.type == Entry.FILECH) { if (e.type == Entry.NEW || e.type == Entry.FILECH || e.type == Entry.COPY) {
IndexNode parent = inodes.get(LOOKUPKEY.as(getParent(e.name))); IndexNode parent = inodes.get(LOOKUPKEY.as(getParent(e.name)));
e.sibling = parent.child; e.sibling = parent.child;
parent.child = e; parent.child = e;
...@@ -2326,12 +2329,12 @@ public class ZipFileSystem extends FileSystem { ...@@ -2326,12 +2329,12 @@ public class ZipFileSystem extends FileSystem {
private void removeFromTree(IndexNode inode) { private void removeFromTree(IndexNode inode) {
IndexNode parent = inodes.get(LOOKUPKEY.as(getParent(inode.name))); IndexNode parent = inodes.get(LOOKUPKEY.as(getParent(inode.name)));
IndexNode child = parent.child; IndexNode child = parent.child;
if (child == inode) { if (child.equals(inode)) {
parent.child = child.sibling; parent.child = child.sibling;
} else { } else {
IndexNode last = child; IndexNode last = child;
while ((child = child.sibling) != null) { while ((child = child.sibling) != null) {
if (child == inode) { if (child.equals(inode)) {
last.sibling = child.sibling; last.sibling = child.sibling;
break; break;
} else { } else {
......
...@@ -138,14 +138,31 @@ public class ZipFSTester { ...@@ -138,14 +138,31 @@ public class ZipFSTester {
Path dst3 = Paths.get(tmpName + "_Tmp"); Path dst3 = Paths.get(tmpName + "_Tmp");
Files.move(dst2, dst3); Files.move(dst2, dst3);
checkEqual(src, dst3); checkEqual(src, dst3);
if (Files.exists(dst2))
throw new RuntimeException("Failed!");
// copyback + move
Files.copy(dst3, dst);
Path dst4 = getPathWithParents(fs, tmpName + "_Tmp0");
Files.move(dst, dst4);
checkEqual(src, dst4);
// delete // delete
if (Files.exists(dst2)) Files.delete(dst4);
if (Files.exists(dst4))
throw new RuntimeException("Failed!"); throw new RuntimeException("Failed!");
Files.delete(dst3); Files.delete(dst3);
if (Files.exists(dst3)) if (Files.exists(dst3))
throw new RuntimeException("Failed!"); throw new RuntimeException("Failed!");
// move (existing entry)
Path dst5 = fs.getPath("META-INF/MANIFEST.MF");
if (Files.exists(dst5)) {
Path dst6 = fs.getPath("META-INF/MANIFEST.MF_TMP");
Files.move(dst5, dst6);
walk(fs.getPath("/"));
}
// newInputStream on dir // newInputStream on dir
Path parent = dst2.getParent(); Path parent = dst2.getParent();
try { try {
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
# #
# @test # @test
# @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 7007596 # @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 7007596
# 7157656 # 7157656 8002390
# @summary Test ZipFileSystem demo # @summary Test ZipFileSystem demo
# @build Basic PathOps ZipFSTester # @build Basic PathOps ZipFSTester
# @run shell basic.sh # @run shell basic.sh
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册