aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/util.php
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-03-20 11:31:28 +0100
committerVincent Petry <pvince81@owncloud.com>2014-03-20 11:31:28 +0100
commit36c0f08ec0c5327f9b38f1078ee0d6ef8823b8da (patch)
treef87533f1a2338101b9b37067071109c9b89dc7c3 /lib/private/util.php
parent970878b5815da97df517688b811265531c7e152f (diff)
parent082c4cda50c6dbb9ba9ca96c641f0db1eeb7ff1a (diff)
downloadnextcloud-server-36c0f08ec0c5327f9b38f1078ee0d6ef8823b8da.tar.gz
nextcloud-server-36c0f08ec0c5327f9b38f1078ee0d6ef8823b8da.zip
Merge pull request #7732 from owncloud/datafolderexistence
Added .ocdata file to check for data folder validity
Diffstat (limited to 'lib/private/util.php')
-rwxr-xr-xlib/private/util.php32
1 files changed, 28 insertions, 4 deletions
diff --git a/lib/private/util.php b/lib/private/util.php
index fc78566e456..70dadb1befd 100755
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -290,13 +290,19 @@ class OC_Util {
* @return array arrays with error messages and hints
*/
public static function checkServer() {
+ $errors = array();
+ $CONFIG_DATADIRECTORY = OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data');
+
+ if (!\OC::needUpgrade() && OC_Config::getValue('installed', false)) {
+ // this check needs to be done every time
+ $errors = self::checkDataDirectoryValidity($CONFIG_DATADIRECTORY);
+ }
+
// Assume that if checkServer() succeeded before in this session, then all is fine.
if(\OC::$session->exists('checkServer_suceeded') && \OC::$session->get('checkServer_suceeded')) {
- return array();
+ return $errors;
}
- $errors = array();
-
$defaults = new \OC_Defaults();
$webServerRestart = false;
@@ -341,7 +347,6 @@ class OC_Util {
);
}
}
- $CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
// Create root dir.
if(!is_dir($CONFIG_DATADIRECTORY)) {
$success=@mkdir($CONFIG_DATADIRECTORY);
@@ -541,6 +546,25 @@ class OC_Util {
}
/**
+ * Check that the data directory exists and is valid by
+ * checking the existence of the ".ocdata" file.
+ *
+ * @param string $dataDirectory data directory path
+ * @return bool true if the data directory is valid, false otherwise
+ */
+ public static function checkDataDirectoryValidity($dataDirectory) {
+ $errors = array();
+ if (!file_exists($dataDirectory.'/.ocdata')) {
+ $errors[] = array(
+ 'error' => 'Data directory (' . $dataDirectory . ') is invalid',
+ 'hint' => 'Please check that the data directory contains a file' .
+ ' ".ocdata" in its root.'
+ );
+ }
+ return $errors;
+ }
+
+ /**
* @return void
*/
public static function displayLoginPage($errors = array()) {