Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
3f891c26
Commit
3f891c26
authored
Mar 28, 2015
by
Vincent Petry
Browse files
Merge pull request #15288 from owncloud/check-datadir-relative
Check for relative datadirectory path
parents
8b9b6006
1511a42d
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/private/util.php
View file @
3f891c26
...
...
@@ -886,17 +886,23 @@ class OC_Util {
* checking the existence of the ".ocdata" file.
*
* @param string $dataDirectory data directory path
* @return
bool true if the data directory is valid, false otherwise
* @return
array errors found
*/
public
static
function
checkDataDirectoryValidity
(
$dataDirectory
)
{
$l
=
\
OC
::
$server
->
getL10N
(
'lib'
);
$errors
=
array
();
$errors
=
[];
if
(
!
self
::
runningOnWindows
()
&&
$dataDirectory
[
0
]
!==
'/'
)
{
$errors
[]
=
[
'error'
=>
$l
->
t
(
'Data directory (%s) must be an absolute path'
,
[
$dataDirectory
]),
'hint'
=>
$l
->
t
(
'Check the value of "datadirectory" in your configuration'
)
];
}
if
(
!
file_exists
(
$dataDirectory
.
'/.ocdata'
))
{
$errors
[]
=
array
(
'error'
=>
$l
->
t
(
'Data directory (%s) is invalid'
,
array
(
$dataDirectory
)
),
$errors
[]
=
[
'error'
=>
$l
->
t
(
'Data directory (%s) is invalid'
,
[
$dataDirectory
]
),
'hint'
=>
$l
->
t
(
'Please check that the data directory contains a file'
.
' ".ocdata" in its root.'
)
)
;
]
;
}
return
$errors
;
}
...
...
tests/lib/util.php
View file @
3f891c26
...
...
@@ -419,6 +419,25 @@ class Test_Util extends \Test\TestCase {
$this
->
assertFalse
(
\
OCP\Util
::
needUpgrade
());
}
public
function
testCheckDataDirectoryValidity
()
{
$dataDir
=
\
OCP\Files
::
tmpFolder
();
touch
(
$dataDir
.
'/.ocdata'
);
$errors
=
\
OC_Util
::
checkDataDirectoryValidity
(
$dataDir
);
$this
->
assertEmpty
(
$errors
);
\
OCP\Files
::
rmdirr
(
$dataDir
);
$dataDir
=
\
OCP\Files
::
tmpFolder
();
// no touch
$errors
=
\
OC_Util
::
checkDataDirectoryValidity
(
$dataDir
);
$this
->
assertNotEmpty
(
$errors
);
\
OCP\Files
::
rmdirr
(
$dataDir
);
if
(
!
\
OC_Util
::
runningOnWindows
())
{
$errors
=
\
OC_Util
::
checkDataDirectoryValidity
(
'relative/path'
);
$this
->
assertNotEmpty
(
$errors
);
}
}
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment