Permalink
Browse files

Move install cache files into plugins/boot.conf instead of cache/ fol…

…der to avoid bad surprise on massive cache clearing.
  • Loading branch information...
1 parent 20d5975 commit 0f1d04e60dcd179b0e16217c0f4b9a0a2244629f @cdujeu cdujeu committed Sep 13, 2016
@@ -59,7 +59,8 @@
define("AJXP_VENDOR_FOLDER", AJXP_INSTALL_PATH."/core/vendor");
define("AJXP_DOCS_FOLDER", "core/doc");
define("AJXP_COREI18N_FOLDER", AJXP_INSTALL_PATH."/plugins/core.ajaxplorer/i18n");
-define("TESTS_RESULT_FILE", AJXP_CACHE_DIR."/diag_result.php");
+define("TESTS_RESULT_FILE", AJXP_DATA_PATH."/plugins/boot.conf/diag_result.php");
+define("TESTS_RESULT_FILE_LEGACY", AJXP_CACHE_DIR."/diag_result.php");
define("AJXP_TESTS_FOLDER", AJXP_BIN_FOLDER."/pydio/Tests");
define("INITIAL_ADMIN_PASSWORD", "admin");
// Startup admin password (used at first creation). Once
@@ -106,7 +106,7 @@ protected function stackMiddleWares(){
}
public function registerCatchAll(){
- if (is_file(TESTS_RESULT_FILE)) {
+ if (is_file(TESTS_RESULT_FILE) || is_file(TESTS_RESULT_FILE_LEGACY)) {
set_error_handler(array($this, "catchError"), E_ALL & ~E_NOTICE & ~E_STRICT );
set_exception_handler(array($this, "catchException"));
}
@@ -256,7 +256,8 @@ public static function getRolesList($roleIds = array(), $excludeReserved = false
*/
public static function bootSequence()
{
- if (file_exists(AJXP_CACHE_DIR . "/admin_counted")) return;
+ $bootConfDir = AJXP_DATA_PATH. "/plugins/boot.conf";
+ if (file_exists(AJXP_CACHE_DIR . "/admin_counted") || file_exists($bootConfDir."/admin_counted")) return;
$rootRole = RolesService::getRole("AJXP_GRP_/");
if ($rootRole === false) {
$rootRole = new AJXP_Role("AJXP_GRP_/");
@@ -348,7 +349,10 @@ public static function bootSequence()
}
RolesService::updateRole($rootRole);
}
- file_put_contents(AJXP_CACHE_DIR . "/admin_counted", "true");
+ if(!file_exists($bootConfDir)){
+ mkdir($bootConfDir, 0666, true);
+ }
+ file_put_contents($bootConfDir . "/admin_counted", "true");
}
}
@@ -38,15 +38,15 @@ class ApplicationState
*/
public static function detectApplicationFirstRun()
{
- return !file_exists(AJXP_CACHE_DIR . "/first_run_passed");
+ return !file_exists(AJXP_CACHE_DIR . "/first_run_passed") && !file_exists(AJXP_DATA_PATH . "/plugins/boot.conf/first_run_passed");
}
/**
* Touch data/cache/first_run_passed file
*/
public static function setApplicationFirstRunPassed()
{
- @file_put_contents(AJXP_CACHE_DIR . "/first_run_passed", "true");
+ @file_put_contents(AJXP_DATA_PATH . "/plugins/boot.conf/first_run_passed", "true");
}
/**
@@ -58,8 +58,12 @@ public function listNodes(ServerRequestInterface $requestInterface, $rootPath, $
$nodesList->appendColumn("ajxp_conf.23", "ajxp_label");
$nodesList->appendColumn("ajxp_conf.24", "data");
- if (is_file(TESTS_RESULT_FILE)) {
- include_once(TESTS_RESULT_FILE);
+ if (is_file(TESTS_RESULT_FILE) || is_file(TESTS_RESULT_FILE_LEGACY)) {
+ if(is_file(TESTS_RESULT_FILE_LEGACY)){
+ include_once(TESTS_RESULT_FILE_LEGACY);
+ }else{
+ include_once(TESTS_RESULT_FILE);
+ }
if (isset($diagResults)) {
foreach ($diagResults as $id => $value) {
$nodeKey = $path."/".$id;
@@ -367,7 +367,10 @@ public function createBootstrapConf($data)
}
$newBootstrap = array("core.conf" => $coreConf, "core.auth" => $coreAuth, "core.cache" => $coreCache);
FileHelper::saveSerialFile($oldBoot, $newBootstrap, true, false, "json", true);
- @unlink(AJXP_CACHE_DIR . "/admin_counted");
+ @unlink($this->getPluginWorkDir(true) . "/admin_counted");
+ if(is_file(AJXP_CACHE_DIR . "/admin_counted")){
+ @unlink(AJXP_CACHE_DIR . "/admin_counted");
+ }
// Write new bootstrap and reload conf plugin!
$coreConf["UNIQUE_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"];
@@ -607,7 +610,10 @@ public function _savePluginConfig($pluginId, $options)
AuthService::disconnect();
} else if ($pluginId == "core.auth") {
// DELETE admin_counted file and DISCONNECT
- @unlink(AJXP_CACHE_DIR . "/admin_counted");
+ @unlink($this->getPluginWorkDir(true) . "/admin_counted");
+ if(is_file(AJXP_CACHE_DIR . "/admin_counted")){
+ @unlink(AJXP_CACHE_DIR . "/admin_counted");
+ }
}
}
}
@@ -218,7 +218,7 @@ public function getBootGui(ServerRequestInterface &$request, ResponseInterface &
$httpVars = $request->getParsedBody();
HTMLWriter::internetExplorerMainDocumentHeader($response);
- if (!is_file(TESTS_RESULT_FILE)) {
+ if (!is_file(TESTS_RESULT_FILE) && !is_file(TESTS_RESULT_FILE_LEGACY)) {
$outputArray = array();
$testedParams = array();
$passed = DiagnosticRunner::runTests($outputArray, $testedParams);

0 comments on commit 0f1d04e

Please sign in to comment.