mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-05-07 10:06:09 +02:00
Ignore submodules in repository archive downloading (#2817)
This commit is contained in:
@@ -1223,34 +1223,37 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
}
|
||||
if (treeWalk != null) {
|
||||
while (treeWalk.next()) {
|
||||
val entryPath =
|
||||
if (path.isEmpty) baseName + "/" + treeWalk.getPathString
|
||||
else path.split("/").last + treeWalk.getPathString.substring(path.length)
|
||||
val mode = treeWalk.getFileMode.getBits
|
||||
JGitUtil.openFile(git, repository, commit.getTree, treeWalk.getPathString) { in =>
|
||||
val tempFile = File.createTempFile("gitbucket", ".archive")
|
||||
val size = Using.resource(new FileOutputStream(tempFile)) { out =>
|
||||
IOUtils.copy(
|
||||
EolStreamTypeUtil.wrapInputStream(
|
||||
in,
|
||||
EolStreamTypeUtil
|
||||
.detectStreamType(
|
||||
OperationType.CHECKOUT_OP,
|
||||
git.getRepository.getConfig.get(WorkingTreeOptions.KEY),
|
||||
treeWalk.getAttributes
|
||||
)
|
||||
),
|
||||
out
|
||||
)
|
||||
}
|
||||
if (treeWalk.getFileMode != FileMode.GITLINK) {
|
||||
val entryPath =
|
||||
if (path.isEmpty) baseName + "/" + treeWalk.getPathString
|
||||
else path.split("/").last + treeWalk.getPathString.substring(path.length)
|
||||
val mode = treeWalk.getFileMode.getBits
|
||||
|
||||
val entry: ArchiveEntry = entryCreator(entryPath, size, date, mode)
|
||||
archive.putArchiveEntry(entry)
|
||||
Using.resource(new FileInputStream(tempFile)) { in =>
|
||||
IOUtils.copy(in, archive)
|
||||
JGitUtil.openFile(git, repository, commit.getTree, treeWalk.getPathString) { in =>
|
||||
val tempFile = File.createTempFile("gitbucket", ".archive")
|
||||
val size = Using.resource(new FileOutputStream(tempFile)) { out =>
|
||||
IOUtils.copy(
|
||||
EolStreamTypeUtil.wrapInputStream(
|
||||
in,
|
||||
EolStreamTypeUtil
|
||||
.detectStreamType(
|
||||
OperationType.CHECKOUT_OP,
|
||||
git.getRepository.getConfig.get(WorkingTreeOptions.KEY),
|
||||
treeWalk.getAttributes
|
||||
)
|
||||
),
|
||||
out
|
||||
)
|
||||
}
|
||||
|
||||
val entry: ArchiveEntry = entryCreator(entryPath, size, date, mode)
|
||||
archive.putArchiveEntry(entry)
|
||||
Using.resource(new FileInputStream(tempFile)) { in =>
|
||||
IOUtils.copy(in, archive)
|
||||
}
|
||||
archive.closeArchiveEntry()
|
||||
tempFile.delete()
|
||||
}
|
||||
archive.closeArchiveEntry()
|
||||
tempFile.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user