diff --git a/README.md b/README.md index 683e73c..5bcc953 100644 --- a/README.md +++ b/README.md @@ -71,11 +71,13 @@ Release Notes ------------- -### 4.14 - 1 Jul 2017 +### 4.14.1 - 4 Jul 2017 +- Bug fix: Possibility of error in forking repository +### 4.14 - 1 Jul 2017 - Support priority in issues and pull requests - Show icons when the sidebar is collapsed -- Support gollumn events in web hook +- Support gollum events in web hook - Support account (user / group) level web hook - Add `--max_file_size` option - Configuration by system property or environment variable diff --git a/build.sbt b/build.sbt index 22e7b81..c941cce 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ val Organization = "io.github.gitbucket" val Name = "gitbucket" -val GitBucketVersion = "4.14.0" +val GitBucketVersion = "4.14.1" val ScalatraVersion = "2.5.0" val JettyVersion = "9.3.19.v20170502" diff --git a/src/main/scala/gitbucket/core/GitBucketCoreModule.scala b/src/main/scala/gitbucket/core/GitBucketCoreModule.scala index 8d678b3..b5a2df8 100644 --- a/src/main/scala/gitbucket/core/GitBucketCoreModule.scala +++ b/src/main/scala/gitbucket/core/GitBucketCoreModule.scala @@ -38,5 +38,6 @@ new Version("4.14.0", new LiquibaseMigration("update/gitbucket-core_4.14.xml"), new SqlMigration("update/gitbucket-core_4.14.sql") - ) + ), + new Version("4.14.1") ) diff --git a/src/main/scala/gitbucket/core/controller/AccountController.scala b/src/main/scala/gitbucket/core/controller/AccountController.scala index c95f4fc..77eaa1a 100644 --- a/src/main/scala/gitbucket/core/controller/AccountController.scala +++ b/src/main/scala/gitbucket/core/controller/AccountController.scala @@ -594,22 +594,23 @@ // Insert default labels insertDefaultLabels(accountName, repository.name) + // Insert default priorities + insertDefaultPriorities(accountName, repository.name) // clone repository actually JGitUtil.cloneRepository( getRepositoryDir(repository.owner, repository.name), - getRepositoryDir(accountName, repository.name)) + FileUtil.deleteIfExists(getRepositoryDir(accountName, repository.name))) // Create Wiki repository - JGitUtil.cloneRepository( - getWikiRepositoryDir(repository.owner, repository.name), - getWikiRepositoryDir(accountName, repository.name)) + JGitUtil.cloneRepository(getWikiRepositoryDir(repository.owner, repository.name), + FileUtil.deleteIfExists(getWikiRepositoryDir(accountName, repository.name))) - // Copy files - FileUtils.copyDirectory( - Directory.getRepositoryFilesDir(repository.owner, repository.name), - Directory.getRepositoryFilesDir(accountName, repository.name) - ) + // Copy LFS files + val lfsDir = getLfsDir(repository.owner, repository.name) + if(lfsDir.exists){ + FileUtils.copyDirectory(lfsDir, FileUtil.deleteIfExists(getLfsDir(accountName, repository.name))) + } // Record activity recordForkActivity(repository.owner, repository.name, loginUserName, accountName) diff --git a/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala b/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala index 7c4bc5e..4ef39e3 100644 --- a/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala @@ -355,7 +355,7 @@ FileUtils.moveDirectory(dir, getAttachedDir(form.newOwner, repository.name)) } } - // Delere parent directory + // Delete parent directory FileUtil.deleteDirectoryIfEmpty(getRepositoryFilesDir(repository.owner, repository.name)) // Call hooks diff --git a/src/main/scala/gitbucket/core/util/FileUtil.scala b/src/main/scala/gitbucket/core/util/FileUtil.scala index 4f2a21d..e31dd6b 100644 --- a/src/main/scala/gitbucket/core/util/FileUtil.scala +++ b/src/main/scala/gitbucket/core/util/FileUtil.scala @@ -68,9 +68,24 @@ def readableSize(size: Long): String = FileUtils.byteCountToDisplaySize(size) + /** + * Delete the given directory if it's empty. + * Do nothing if the given File is not a directory or not empty. + */ def deleteDirectoryIfEmpty(dir: File): Unit = { if(dir.isDirectory() && dir.list().isEmpty) { FileUtils.deleteDirectory(dir) } } + + /** + * Delete file or directory forcibly. + */ + def deleteIfExists(file: java.io.File): java.io.File = { + if(file.exists){ + FileUtils.forceDelete(file) + } + file + } + }