Merge pull request #25 from mmattel/Fix_for_non_Windows_Fileservers

Fix for allfinfo and parsStat for non Windows Fileservers
This commit is contained in:
Robin Appelman 2015-04-10 14:10:08 +02:00
commit 4f5d9db3a9
2 changed files with 11 additions and 0 deletions

View file

@ -92,6 +92,11 @@ class Parser {
$size = 0; $size = 0;
foreach ($output as $line) { foreach ($output as $line) {
list($name, $value) = explode(':', $line, 2); list($name, $value) = explode(':', $line, 2);
// A line = explode statement may not fill all array elements
// properly. May happen when accessing non Windows Fileservers
$words = explode(':', $line, 2);
$name = isset($words[0]) ? $words[0] : '';
$value = isset($words[1]) ? $words[1] : '';
$value = trim($value); $value = trim($value);
if ($name === 'write_time') { if ($name === 'write_time') {
$mtime = strtotime($value); $mtime = strtotime($value);

View file

@ -120,6 +120,12 @@ class Share implements IShare {
public function stat($path) { public function stat($path) {
$escapedPath = $this->escapePath($path); $escapedPath = $this->escapePath($path);
$output = $this->execute('allinfo ' . $escapedPath); $output = $this->execute('allinfo ' . $escapedPath);
// Windows and non Windows Fileserver may respond different
// to the allinfo command for directories. If the result is a single
// line = error line, redo it with a different allinfo parameter
if ($escapedPath == '""' && count($output) < 2) {
$output = $this->execute('allinfo ' . '"."');
}
if (count($output) < 3) { if (count($output) < 3) {
$this->parseOutput($output, $path); $this->parseOutput($output, $path);
} }