public function cleanupOldFiles() { $_SESSION['DB_DONE'] = true; $cleanupList = array_merge($this->pluginFinder->getDummyPlugins(), $this->filesFinder->getCleanupFiles()); $this->cleanupMedia(); if (count($cleanupList) == 0) { $_SESSION['CLEANUP_DONE'] = true; $this->response->redirect($this->app->urlFor('done')); } if ($this->request->isPost()) { $result = []; foreach ($cleanupList as $path) { $result = array_merge($result, Utils::cleanPath($path)); } if (count($result) == 0) { $_SESSION['CLEANUP_DONE'] = true; $this->response->redirect($this->app->urlFor('done')); } else { $result = array_map(function ($path) { return substr($path, strlen(SW_PATH) + 1); }, $result); $this->app->render('cleanup.php', ['cleanupList' => $result, 'error' => true]); } } else { $cleanupList = array_map(function ($path) { return substr($path, strlen(SW_PATH) + 1); }, $cleanupList); $this->app->render('cleanup.php', ['cleanupList' => $cleanupList, 'error' => false]); } }
$cleanupList = array(); foreach ($rawList as $path) { $realpath = SW_PATH . '/' . $path; if (file_exists($realpath)) { $cleanupList[] = $path; } } if (count($cleanupList) == 0) { $_SESSION['CLEANUP_DONE'] = true; $url = $app->urlFor('done'); $app->response()->redirect($url); } if ($app->request()->isPost()) { $result = array(); foreach ($cleanupList as $path) { $result = array_merge($result, Utils::cleanPath(SW_PATH . '/' . $path)); } if (count($result) == 0) { $_SESSION['CLEANUP_DONE'] = true; $url = $app->urlFor('done'); $app->response()->redirect($url); } else { $result = array_map(function ($path) { return substr($path, strlen(realpath(__DIR__ . '/../../../')) + 1); }, $result); $app->render('cleanup.php', array('cleanupList' => $result, 'error' => true)); } } else { $app->render('cleanup.php', array('cleanupList' => $cleanupList, 'error' => false)); } })->via('GET', 'POST')->name('cleanup');
private function cleanupFiles() { /** @var CleanupFilesFinder $cleanupFilesFinder */ $cleanupFilesFinder = $this->container->get('cleanup.files.finder'); foreach ($cleanupFilesFinder->getCleanupFiles() as $path) { Utils::cleanPath($path); } }
private function cleanup() { $this->output->writeln("Cleanup old files, clearing caches..."); $cleanupFile = UPDATE_ASSET_PATH . '/cleanup.php'; if (!is_file($cleanupFile)) { return; } $rawList = (require $cleanupFile); $cleanupList = array(); foreach ($rawList as $path) { $realpath = SW_PATH . '/' . $path; if (file_exists($realpath)) { $cleanupList[] = $path; } } foreach ($cleanupList as $path) { Utils::cleanPath(SW_PATH . '/' . $path); } $directoriesToDelete = array('cache/proxies/' => false, 'cache/doctrine/filecache/' => false, 'cache/doctrine/proxies/' => false, 'cache/doctrine/attributes/' => false, 'cache/general/' => false, 'cache/templates/' => false, 'engine/Library/Mpdf/tmp' => false, 'engine/Library/Mpdf/ttfontdata' => false); foreach ($directoriesToDelete as $directory => $deleteDirecory) { $filePath = SW_PATH . '/' . $directory; Utils::deleteDir($filePath, $deleteDirecory); } }