some more error reporting during filesystem scan

This commit is contained in:
Robin Appelman 2012-02-25 20:27:16 +01:00
parent dda79a90cf
commit 4f627c428e
3 changed files with 42 additions and 9 deletions

View File

@ -794,7 +794,7 @@ class MDB2_Driver_mysql extends MDB2_Driver_Common
? 'mysql_query' : 'mysql_unbuffered_query';
$result = @$function($query, $connection);
if (!$result) {
$err =& $this->raiseError(null, null, null,
$err =$this->raiseError(null, null, null,
'Could not execute statement', __FUNCTION__);
return $err;
}

View File

@ -508,6 +508,21 @@ class OC_DB {
self::$connection->commit();
self::$inTransaction=false;
}
/**
* check if a result is an error, works with MDB2 and PDOException
* @param mixed $result
* @return bool
*/
public static function isError($result){
if(!$result){
return true;
}elseif(self::$backend==self::BACKEND_MDB2 and PEAR::isError($result)){
return true;
}else{
return false;
}
}
}
/**
@ -527,11 +542,15 @@ class PDOStatementWrapper{
public function execute($input=array()){
$this->lastArguments=$input;
if(count($input)>0){
$this->statement->execute($input);
$result=$this->statement->execute($input);
}else{
$this->statement->execute();
$result=$this->statement->execute();
}
if($result){
return $this;
}else{
return false;
}
return $this;
}
/**

View File

@ -102,8 +102,10 @@ class OC_FileCache{
$mimePart=dirname($data['mimetype']);
$user=OC_User::getUser();
$query=OC_DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart,user,writable) VALUES(?,?,?,?,?,?,?,?,?,?)');
$query->execute(array($parent,basename($path),$path,$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user,$data['writable']));
$result=$query->execute(array($parent,basename($path),$path,$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user,$data['writable']));
if(OC_DB::isError($result)){
OC_Log::write('files','error while writing file('.$path.') to cache',OC_Log::ERROR);
}
}
/**
@ -128,7 +130,10 @@ class OC_FileCache{
$sql = 'UPDATE *PREFIX*fscache SET '.implode(' , ',$queryParts).' WHERE id=?';
$query=OC_DB::prepare($sql);
$query->execute($arguments);
$result=$query->execute($arguments);
if(OC_DB::isError($result)){
OC_Log::write('files','error while updating file('.$path.') in cache',OC_Log::ERROR);
}
}
/**
@ -262,11 +267,20 @@ class OC_FileCache{
*/
private static function getFileId($path){
$query=OC_DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path=?');
$result=$query->execute(array($path))->fetchRow();
if(OC_DB::isError($query)){
OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR);
return -1;
}
$result=$query->execute(array($path));
if(OC_DB::isError($result)){
OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR);
return -1;
}
$result=$result->fetchRow();
if(is_array($result)){
return $result['id'];
}else{
OC_Log::write('getFileId(): file not found in cache ('.$path.')','core',OC_Log::DEBUG);
OC_Log::write('getFileId(): file not found in cache ('.$path.')','core',OC_Log::DEBUG);
return -1;
}
}