Skip to content

Commit 6bb8ed5

Browse files
committed
Move logic to preparing step
1 parent e54320e commit 6bb8ed5

File tree

2 files changed

+63
-64
lines changed

2 files changed

+63
-64
lines changed

resources/views/components/finishing.blade.php

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Illuminate\Support\Facades\File;
88
use Database\Seeders\ButtonSeeder;
99
use App\Models\Page;
10-
use App\Models\Link;
1110
1211
set_time_limit(0);
1312
@@ -430,66 +429,4 @@
430429
session(['update_error' => $e->getMessage()]);
431430
}
432431
433-
try {
434-
435-
$links = Link::where('button_id', 94)->get()->groupBy('user_id');
436-
437-
foreach ($links as $userId => $userLinks) {
438-
$hasXTwitter = $userLinks->contains('title', 'x-twitter');
439-
440-
foreach ($userLinks as $link) {
441-
if ($link->title == 'twitter') {
442-
if ($hasXTwitter) {
443-
$link->delete();
444-
} else {
445-
$link->title = 'x-twitter';
446-
$link->save();
447-
$hasXTwitter = true;
448-
}
449-
}
450-
}
451-
}
452-
453-
} catch (exception $e) {
454-
session(['update_error' => $e->getMessage()]);
455-
}
456-
457-
try {
458-
459-
$themesPath = base_path('themes');
460-
$regex = '/[0-9.-]/';
461-
$files = scandir($themesPath);
462-
$files = array_diff($files, array('.', '..'));
463-
464-
$themeError = 'The update was successful. Your theme-filesystem was detected as corrupted and has been reset.';
465-
466-
foreach ($files as $file) {
467-
468-
$basename = basename($file);
469-
$filePath = $themesPath . '/' . $basename;
470-
471-
if (!is_dir($filePath)) {
472-
473-
File::deleteDirectory($themesPath);
474-
mkdir($themesPath);
475-
session(['update_error' => $themeError]);
476-
break;
477-
478-
}
479-
480-
if (preg_match($regex, $basename)) {
481-
482-
$newBasename = preg_replace($regex, '', $basename);
483-
$newPath = $themesPath . '/' . $newBasename;
484-
File::copyDirectory($filePath, $newPath);
485-
File::deleteDirectory($filePath);
486-
487-
}
488-
489-
}
490-
491-
} catch (exception $e) {
492-
session(['update_error' => $e->getMessage()]);
493-
}
494-
495-
?>
432+
?>

resources/views/components/pre-update.blade.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,66 @@
8080
$link->save();
8181
}
8282
}
83+
}
84+
85+
try {
86+
87+
$links = Link::where('button_id', 94)->get()->groupBy('user_id');
88+
89+
foreach ($links as $userId => $userLinks) {
90+
$hasXTwitter = $userLinks->contains('title', 'x-twitter');
91+
92+
foreach ($userLinks as $link) {
93+
if ($link->title == 'twitter') {
94+
if ($hasXTwitter) {
95+
$link->delete();
96+
} else {
97+
$link->title = 'x-twitter';
98+
$link->save();
99+
$hasXTwitter = true;
100+
}
101+
}
102+
}
103+
}
104+
105+
} catch (exception $e) {
106+
session(['update_error' => $e->getMessage()]);
107+
}
108+
109+
try {
110+
111+
$themesPath = base_path('themes');
112+
$regex = '/[0-9.-]/';
113+
$files = scandir($themesPath);
114+
$files = array_diff($files, array('.', '..'));
115+
116+
$themeError = 'Your theme-filesystem was detected as corrupted and has been reset. Rerun the updater to complete the update.';
117+
118+
foreach ($files as $file) {
119+
120+
$basename = basename($file);
121+
$filePath = $themesPath . '/' . $basename;
122+
123+
if (!is_dir($filePath)) {
124+
125+
File::deleteDirectory($themesPath);
126+
mkdir($themesPath);
127+
session(['update_error' => $themeError]);
128+
break;
129+
130+
}
131+
132+
if (preg_match($regex, $basename)) {
133+
134+
$newBasename = preg_replace($regex, '', $basename);
135+
$newPath = $themesPath . '/' . $newBasename;
136+
File::copyDirectory($filePath, $newPath);
137+
File::deleteDirectory($filePath);
138+
139+
}
140+
141+
}
142+
143+
} catch (exception $e) {
144+
session(['update_error' => $e->getMessage()]);
83145
}

0 commit comments

Comments
 (0)