Skip to content

Commit d5721ae

Browse files
committed
Check themes folder when updating
1 parent d69558a commit d5721ae

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

resources/views/components/finishing.blade.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,4 +429,42 @@
429429
session(['update_error' => $e->getMessage()]);
430430
}
431431
432+
try {
433+
434+
$themesPath = base_path('themes');
435+
$regex = '/[0-9.-]/';
436+
$files = scandir($themesPath);
437+
$files = array_diff($files, array('.', '..'));
438+
439+
$themeError = 'The update was successful. Your theme-filesystem was detected as corrupted and has been reset.';
440+
441+
foreach ($files as $file) {
442+
443+
$basename = basename($file);
444+
$filePath = $themesPath . '/' . $basename;
445+
446+
if (!is_dir($filePath)) {
447+
448+
File::deleteDirectory($themesPath);
449+
mkdir($themesPath);
450+
session(['update_error' => $themeError]);
451+
break;
452+
453+
}
454+
455+
if (preg_match($regex, $basename)) {
456+
457+
$newBasename = preg_replace($regex, '', $basename);
458+
$newPath = $themesPath . '/' . $newBasename;
459+
File::copyDirectory($filePath, $newPath);
460+
File::deleteDirectory($filePath);
461+
462+
}
463+
464+
}
465+
466+
} catch (exception $e) {
467+
session(['update_error' => $e->getMessage()]);
468+
}
469+
432470
?>

0 commit comments

Comments
 (0)