mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-10 15:35:59 +01:00
(refs #2048)Fix archive downloading
This commit is contained in:
@@ -822,12 +822,43 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download repository contents as an archive as compatible URL.
|
* Download repository contents as a zip archive as compatible URL.
|
||||||
*/
|
*/
|
||||||
get("/:owner/:repository/archive/:branch.:suffix")(referrersOnly { repository =>
|
get("/:owner/:repository/archive/:branch.zip")(referrersOnly { repository =>
|
||||||
val branch = params("branch")
|
val branch = params("branch")
|
||||||
val suffix = params("suffix")
|
archiveRepository(branch, branch + ".zip", repository, "")
|
||||||
archiveRepository(branch, branch + "." + suffix, repository, "")
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Download repository contents as a tar.gz archive as compatible URL.
|
||||||
|
*/
|
||||||
|
get("/:owner/:repository/archive/:branch.tar.gz")(referrersOnly { repository =>
|
||||||
|
val branch = params("branch")
|
||||||
|
archiveRepository(branch, branch + ".tar.gz", repository, "")
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Download repository contents as a tar.gz archive as compatible URL.
|
||||||
|
*/
|
||||||
|
get("/:owner/:repository/archive/:branch.tar.gz")(referrersOnly { repository =>
|
||||||
|
val branch = params("branch")
|
||||||
|
archiveRepository(branch, branch + ".tar.gz", repository, "")
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Download repository contents as a tar.bz2 archive as compatible URL.
|
||||||
|
*/
|
||||||
|
get("/:owner/:repository/archive/:branch.tar.bz2")(referrersOnly { repository =>
|
||||||
|
val branch = params("branch")
|
||||||
|
archiveRepository(branch, branch + ".tar.bz2", repository, "")
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Download repository contents as a tar.xz archive as compatible URL.
|
||||||
|
*/
|
||||||
|
get("/:owner/:repository/archive/:branch.tar.xz")(referrersOnly { repository =>
|
||||||
|
val branch = params("branch")
|
||||||
|
archiveRepository(branch, branch + ".tar.bz2", repository, "")
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1134,7 +1165,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def archiveRepository(
|
private def archiveRepository(
|
||||||
revision: String,
|
revision: String,
|
||||||
filename: String,
|
filename: String,
|
||||||
repository: RepositoryService.RepositoryInfo,
|
repository: RepositoryService.RepositoryInfo,
|
||||||
@@ -1176,7 +1207,8 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val suffix = path.split("/").lastOption.map("-" + _).getOrElse("")
|
val suffix =
|
||||||
|
path.split("/").lastOption.collect { case x if x.length > 0 => "-" + x.replace('/', '_') }.getOrElse("")
|
||||||
val zipRe = """(.+)\.zip$""".r
|
val zipRe = """(.+)\.zip$""".r
|
||||||
val tarRe = """(.+)\.tar\.(gz|bz2|xz)$""".r
|
val tarRe = """(.+)\.tar\.(gz|bz2|xz)$""".r
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user