added some additional error handling
This commit is contained in:
parent
eafd34684c
commit
0c8bcacdc8
|
@ -53,8 +53,14 @@ class Trashbin {
|
||||||
|
|
||||||
self::copy_recursive($file_path, 'files_trashbin/'.$deleted.'.d'.$timestamp, $view);
|
self::copy_recursive($file_path, 'files_trashbin/'.$deleted.'.d'.$timestamp, $view);
|
||||||
|
|
||||||
|
if ( $view->file_exists('files_trashbin/'.$deleted.'.d'.$timestamp) ) {
|
||||||
$query = \OC_DB::prepare("INSERT INTO *PREFIX*files_trash (id,timestamp,location,type,mime,user) VALUES (?,?,?,?,?,?)");
|
$query = \OC_DB::prepare("INSERT INTO *PREFIX*files_trash (id,timestamp,location,type,mime,user) VALUES (?,?,?,?,?,?)");
|
||||||
$query->execute(array($deleted, $timestamp, $location, $type, $mime, $user));
|
$result = $query->execute(array($deleted, $timestamp, $location, $type, $mime, $user));
|
||||||
|
if ( !$result ) { // if file couldn't be added to the database than also don't store it in the trash bin.
|
||||||
|
$view->deleteAll('files_trashbin/'.$deleted.'.d'.$timestamp);
|
||||||
|
\OC_Log::write('files_trashbin', 'trash bin database couldn\'t be updated', \OC_log::ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( \OCP\App::isEnabled('files_versions') ) {
|
if ( \OCP\App::isEnabled('files_versions') ) {
|
||||||
if ( $view->is_dir('files_versions'.$file_path) ) {
|
if ( $view->is_dir('files_versions'.$file_path) ) {
|
||||||
|
@ -65,6 +71,9 @@ class Trashbin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
\OC_Log::write('files_trashbin', 'Couldn\'t move '.$file_path.' to the trash bin' , \OC_log::ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
self::expire();
|
self::expire();
|
||||||
}
|
}
|
||||||
|
@ -133,6 +142,8 @@ class Trashbin {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
\OC_Log::write('files_trashbin', 'Couldn\'t restore file from trash bin, '.$filename , \OC_log::ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue