mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-14 20:42:21 +00:00
[FIXED JENKINS-10629] Unbroke stream with new tar implementation.
Causes bytes lost and truncated tar archive. TarBuffer not used in TarArchiveOutputStream.
This commit is contained in:
1 parent
2ef29215c2
commit
3e187a0264
2 files changed
+32
-9
No files matched your search
@@ -659,4 +659,35 @@ public class FilePathTest {
|
||||
// test conflict subdir
|
||||
src.moveAllChildrenTo(dst);
|
||||
}
|
||||
|
||||
@Issue("JENKINS-10629")
|
||||
@Test
|
||||
public void testEOFbrokenFlush() throws IOException, InterruptedException {
|
||||
final File srcFolder = temp.newFolder("src");
|
||||
// simulate magic structure with magic sizes:
|
||||
// |- dir/pom.xml (2049)
|
||||
// |- pom.xml (2049)
|
||||
// \- small.tar (1537)
|
||||
final File smallTar = new File(srcFolder, "small.tar");
|
||||
givenSomeContentInFile(smallTar, 1537);
|
||||
final File dir = new File(srcFolder, "dir");
|
||||
dir.mkdirs();
|
||||
final File pomFile = new File(dir, "pom.xml");
|
||||
givenSomeContentInFile(pomFile, 2049);
|
||||
FileUtils.copyFileToDirectory(pomFile, srcFolder);
|
||||
|
||||
final File archive = temp.newFile("archive.tar");
|
||||
|
||||
// Compress archive
|
||||
final FilePath tmpDirPath = new FilePath(srcFolder);
|
||||
int tarred = tmpDirPath.tar(new FileOutputStream(archive), "**");
|
||||
assertEquals("One file should have been compressed", 3, tarred);
|
||||
|
||||
// Decompress
|
||||
final File dstFolder = temp.newFolder("dst");
|
||||
dstFolder.mkdirs();
|
||||
FilePath outDir = new FilePath(dstFolder);
|
||||
// and now fail when flush is bad!
|
||||
tmpDirPath.child("../" + archive.getName()).untar(outDir, TarCompression.NONE);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user