mirror of https://github.com/halo-dev/halo
Enhance theme fetching api
parent
0050213f49
commit
bd7b87aa50
|
@ -440,10 +440,11 @@ public class ThemeServiceImpl implements ThemeService {
|
||||||
// Create temp path
|
// Create temp path
|
||||||
Path themeTmpPath = tmpPath.resolve(HaloUtils.randomUUIDWithoutDash());
|
Path themeTmpPath = tmpPath.resolve(HaloUtils.randomUUIDWithoutDash());
|
||||||
|
|
||||||
if (StringUtils.endsWithIgnoreCase(uri, ".git")) {
|
if (StringUtils.endsWithIgnoreCase(uri, ".zip")) {
|
||||||
cloneFromGit(uri, themeTmpPath);
|
|
||||||
} else {
|
|
||||||
downloadZipAndUnzip(uri, themeTmpPath);
|
downloadZipAndUnzip(uri, themeTmpPath);
|
||||||
|
} else {
|
||||||
|
uri = StringUtils.appendIfMissingIgnoreCase(uri, ".git", ".git");
|
||||||
|
cloneFromGit(uri, themeTmpPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return add(themeTmpPath);
|
return add(themeTmpPath);
|
||||||
|
@ -464,7 +465,7 @@ public class ThemeServiceImpl implements ThemeService {
|
||||||
*
|
*
|
||||||
* @param gitUrl git url must not be blank
|
* @param gitUrl git url must not be blank
|
||||||
* @param targetPath target path must not be null
|
* @param targetPath target path must not be null
|
||||||
* @throws GitAPIException
|
* @throws GitAPIException throws when clone error
|
||||||
*/
|
*/
|
||||||
private void cloneFromGit(@NonNull String gitUrl, @NonNull Path targetPath) throws GitAPIException {
|
private void cloneFromGit(@NonNull String gitUrl, @NonNull Path targetPath) throws GitAPIException {
|
||||||
Assert.hasText(gitUrl, "Git url must not be blank");
|
Assert.hasText(gitUrl, "Git url must not be blank");
|
||||||
|
@ -486,7 +487,7 @@ public class ThemeServiceImpl implements ThemeService {
|
||||||
*
|
*
|
||||||
* @param zipUrl zip url must not be null
|
* @param zipUrl zip url must not be null
|
||||||
* @param targetPath target path must not be null
|
* @param targetPath target path must not be null
|
||||||
* @throws IOException
|
* @throws IOException throws when download zip or unzip error
|
||||||
*/
|
*/
|
||||||
private void downloadZipAndUnzip(@NonNull String zipUrl, @NonNull Path targetPath) throws IOException {
|
private void downloadZipAndUnzip(@NonNull String zipUrl, @NonNull Path targetPath) throws IOException {
|
||||||
Assert.hasText(zipUrl, "Zip url must not be blank");
|
Assert.hasText(zipUrl, "Zip url must not be blank");
|
||||||
|
@ -514,7 +515,7 @@ public class ThemeServiceImpl implements ThemeService {
|
||||||
* Creates temporary path.
|
* Creates temporary path.
|
||||||
*
|
*
|
||||||
* @return temporary path
|
* @return temporary path
|
||||||
* @throws IOException
|
* @throws IOException if an I/O error occurs or the temporary-file directory does not exist
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
private Path createTempPath() throws IOException {
|
private Path createTempPath() throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue