Fix WebDAV external storage opendir() and stat() for directories, bug fix for oc-1160

remotes/origin/stable45
Michael Gapczynski 13 years ago
parent 3ed7738d5e
commit 719c7f7f6e
  1. 26
      apps/files_external/lib/webdav.php

@ -73,13 +73,15 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
$stripLength=strlen($this->root)+strlen($path); $stripLength=strlen($this->root)+strlen($path);
$id=md5('webdav'.$this->root.$path); $id=md5('webdav'.$this->root.$path);
OC_FakeDirStream::$dirs[$id]=array(); OC_FakeDirStream::$dirs[$id]=array();
$skip = true;
foreach($response as $file=>$data){ foreach($response as $file=>$data){
//strip root and path // Skip the first file, because it is the current directory
$file=trim(substr($file,$stripLength)); if ($skip) {
$file=trim($file,'/'); $skip = false;
if($file){ continue;
OC_FakeDirStream::$dirs[$id][]=$file;
} }
$file = urldecode(basename($file));
OC_FakeDirStream::$dirs[$id][]=$file;
} }
return opendir('fakedir://'.$id); return opendir('fakedir://'.$id);
}catch(Exception $e){ }catch(Exception $e){
@ -244,15 +246,11 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
$path=$this->cleanPath($path); $path=$this->cleanPath($path);
try{ try{
$response=$this->client->propfind($path, array('{DAV:}getlastmodified','{DAV:}getcontentlength')); $response=$this->client->propfind($path, array('{DAV:}getlastmodified','{DAV:}getcontentlength'));
if(isset($response['{DAV:}getlastmodified']) and isset($response['{DAV:}getcontentlength'])){ return array(
return array( 'mtime'=>strtotime($response['{DAV:}getlastmodified']),
'mtime'=>strtotime($response['{DAV:}getlastmodified']), 'size'=>(int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0,
'size'=>(int)$response['{DAV:}getcontentlength'], 'ctime'=>-1,
'ctime'=>-1, );
);
}else{
return array();
}
}catch(Exception $e){ }catch(Exception $e){
return array(); return array();
} }

Loading…
Cancel
Save