mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
Bugfix for long filenames in tar (#1552)
Fixes errors with long file names in tar archives. This may arise with hg repositories with deep directories.
This commit is contained in:
@@ -42,6 +42,7 @@ import java.nio.file.StandardCopyOption;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static sonia.scm.util.Archives.createTarInputStream;
|
||||
|
||||
class GitBundleCommandTest {
|
||||
|
||||
@@ -94,7 +95,7 @@ class GitBundleCommandTest {
|
||||
}
|
||||
|
||||
private void assertStreamContainsContent(ByteArrayOutputStream baos, String content) throws IOException {
|
||||
TarArchiveInputStream tais = new TarArchiveInputStream(new BufferedInputStream(new ByteArrayInputStream(baos.toByteArray())));
|
||||
TarArchiveInputStream tais = createTarInputStream(new BufferedInputStream(new ByteArrayInputStream(baos.toByteArray())));
|
||||
tais.getNextEntry();
|
||||
|
||||
byte[] result = IOUtils.toByteArray(tais);
|
||||
|
||||
@@ -30,8 +30,8 @@ import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import sonia.scm.util.Archives;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -82,9 +82,10 @@ class GitUnbundleCommandTest extends AbstractGitCommandTestBase {
|
||||
|
||||
private UnbundleCommandRequest createUnbundleCommandRequestForFile(Path temp, String filePath, String fileContent) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
TarArchiveOutputStream taos = new TarArchiveOutputStream(baos);
|
||||
TarArchiveOutputStream taos = Archives.createTarOutputStream(baos);
|
||||
addEntry(taos, filePath, fileContent);
|
||||
taos.finish();
|
||||
taos.close();
|
||||
|
||||
when(gitContext.getDirectory()).thenReturn(temp.toFile());
|
||||
ByteSource byteSource = ByteSource.wrap(baos.toByteArray());
|
||||
|
||||
Reference in New Issue
Block a user