@ -80,7 +80,7 @@ class Legacy {
}
}
$result = $query->execute(array($path));
$result = $query->execute(array($path));
$data = $result->fetchRow();
$data = $result->fetchRow();
$data['etag'] = $this->getEtag($data['path']);
$data['etag'] = $this->getEtag($data['path'], $data['user'] );
return $data;
return $data;
}
}
@ -90,12 +90,24 @@ class Legacy {
* @param type $path
* @param type $path
* @return string
* @return string
*/
*/
function getEtag($path) {
function getEtag($path, $user = null ) {
static $query = null;
static $query = null;
list(, $user, , $relativePath) = explode('/', $path, 4);
if (is_null($relativePath)) {
$pathDetails = explode('/', $path, 4);
if((!$user) & & !isset($pathDetails[1])) {
//no user!? Too odd, return empty string.
return '';
} else if(!$user) {
//guess user from path, if no user passed.
$user = $pathDetails[1];
}
if(!isset($pathDetails[3]) || is_null($pathDetails[3])) {
$relativePath = '';
$relativePath = '';
} else {
$relativePath = $pathDetails[3];
}
}
if(is_null($query)){
if(is_null($query)){
$query = \OC_DB::prepare('SELECT `propertyvalue` FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = \'{DAV:}getetag\'');
$query = \OC_DB::prepare('SELECT `propertyvalue` FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = \'{DAV:}getetag\'');
}
}
@ -118,7 +130,7 @@ class Legacy {
$result = $query->execute(array($id));
$result = $query->execute(array($id));
$data = $result->fetchAll();
$data = $result->fetchAll();
foreach ($data as $i => $item) {
foreach ($data as $i => $item) {
$data[$i]['etag'] = $this->getEtag($item['path']);
$data[$i]['etag'] = $this->getEtag($item['path'], $item['user'] );
}
}
return $data;
return $data;
}
}