Skip to content

Commit

Permalink
0.93.27 Fix copying configs on initial start
Browse files Browse the repository at this point in the history
  • Loading branch information
araszka committed Aug 19, 2020
1 parent 26a37a1 commit 667cbe0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 26 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.93.25
0.93.26
53 changes: 30 additions & 23 deletions core/Classes/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,25 +234,6 @@ public static function makeDir(string $dir)
}
}

private static function createDirUntilExists(string $startDir)
{
$levels = collect(explode(DIRECTORY_SEPARATOR, $startDir));

if ($levels->last() == "") {
$levels->pop();
}

$toCreate = $levels->implode(DIRECTORY_SEPARATOR);
$levels->pop();
$parentDir = $levels->implode(DIRECTORY_SEPARATOR);

if (!is_dir($parentDir)) {
self::createDirUntilExists($parentDir);
}

mkdir($toCreate);
}

/**
* @param string $sourceFile
* @param string $targetFile
Expand All @@ -263,8 +244,8 @@ public static function rename(string $sourceFile, string $targetFile)
$sourceFile = str_replace('/', DIRECTORY_SEPARATOR, $sourceFile);
$targetFile = str_replace('/', DIRECTORY_SEPARATOR, $targetFile);

if (!self::dirExists($targetFile)) {
self::makeDir($targetFile);
if (!self::dirExists(dirname($targetFile))) {
self::makeDir(dirname($targetFile));
}

rename($sourceFile, $targetFile);
Expand All @@ -280,10 +261,36 @@ public static function copy(string $source, string $target)
$source = str_replace('/', DIRECTORY_SEPARATOR, $source);
$target = str_replace('/', DIRECTORY_SEPARATOR, $target);

if (!self::dirExists($target)) {
self::makeDir($target);
if (!self::dirExists(dirname($target))) {
self::makeDir(dirname($target));
}

copy($source, $target);
}

/**
* PRIVATE METHODS
*/

/**
* @param string $startDir
*/
private static function createDirUntilExists(string $startDir)
{
$levels = collect(explode(DIRECTORY_SEPARATOR, $startDir));

if ($levels->last() == "") {
$levels->pop();
}

$toCreate = $levels->implode(DIRECTORY_SEPARATOR);
$levels->pop();
$parentDir = $levels->implode(DIRECTORY_SEPARATOR);

if (!is_dir($parentDir)) {
self::createDirUntilExists($parentDir);
}

mkdir($toCreate);
}
}
9 changes: 7 additions & 2 deletions core/Classes/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private static function writeLn(string $line)
*/
public static function write(string $string, $echo = true, $caller = null)
{

if (!$caller) {
list($childClass, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
}
Expand All @@ -74,6 +75,12 @@ public static function write(string $string, $echo = true, $caller = null)
}

$time = date("H:i:s", time());
$line = sprintf("[%s] %s(): %s", $time, $callingClass, $string);

if (!isset(self::$singleFileMode)) {
echo $line . "\n";
return;
}

if (self::$singleFileMode) {
$logFile = logDir(self::$logPrefix . '.txt');
Expand All @@ -82,8 +89,6 @@ public static function write(string $string, $echo = true, $caller = null)
$logFile = logDir(self::$logPrefix . '_' . $date . '.txt');
}

$line = sprintf("[%s] %s(): %s", $time, $callingClass, $string);

$line = stripAll($line);

if ($echo == true || isDebug()) {
Expand Down

0 comments on commit 667cbe0

Please sign in to comment.