aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-07-07 14:10:32 +0200
committerGitHub <noreply@github.com>2017-07-07 14:10:32 +0200
commite76b867c2c4704e6c760b80bcb9ac1354c29f54e (patch)
treeaef0b7bbd2a882c397ad10ebf01204f9f79e5572 /core
parentc2ba5e2884cad679d8d02dfe7976401c3b03e9ee (diff)
parent79d7c26b8a7c5ed99f5002163343132302d70111 (diff)
downloadnextcloud-server-e76b867c2c4704e6c760b80bcb9ac1354c29f54e.tar.gz
nextcloud-server-e76b867c2c4704e6c760b80bcb9ac1354c29f54e.zip
Merge pull request #5628 from nextcloud/only-create-the-migration-dir-when-necessary
Only create the migration directory when necessary
Diffstat (limited to 'core')
-rw-r--r--core/Command/Db/Migrations/GenerateCommand.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/Command/Db/Migrations/GenerateCommand.php b/core/Command/Db/Migrations/GenerateCommand.php
index b6e1a17d683..e6c38d06e5d 100644
--- a/core/Command/Db/Migrations/GenerateCommand.php
+++ b/core/Command/Db/Migrations/GenerateCommand.php
@@ -136,6 +136,8 @@ class <classname> extends SimpleMigrationStep {
];
$code = str_replace($placeHolders, $replacements, self::$_templateSimple);
$dir = $ms->getMigrationsDirectory();
+
+ $this->ensureMigrationDirExists($dir);
$path = $dir . '/' . $className . '.php';
if (file_put_contents($path, $code) === false) {
@@ -145,4 +147,19 @@ class <classname> extends SimpleMigrationStep {
return $path;
}
+ private function ensureMigrationDirExists($directory) {
+ if (file_exists($directory) && is_dir($directory)) {
+ return;
+ }
+
+ if (file_exists($directory)) {
+ throw new \RuntimeException("Could not create folder \"$directory\"");
+ }
+
+ $this->ensureMigrationDirExists(dirname($directory));
+
+ if (!@mkdir($directory) && !is_dir($directory)) {
+ throw new \RuntimeException("Could not create folder \"$directory\"");
+ }
+ }
}