Error logging on save

pull/1/head
Victor Dubiniuk 11 years ago
parent 158db50966
commit cc1a5d5945

@ -92,22 +92,42 @@ class SessionController extends Controller{
*/ */
public static function save(){ public static function save(){
$uid = self::preDispatch(); $uid = self::preDispatch();
$sessionID = @$_SERVER['HTTP_WEBODF_SESSION_ID']; try {
$memberId = @$_SERVER['HTTP_WEBODF_MEMBER_ID']; $sessionID = @$_SERVER['HTTP_WEBODF_SESSION_ID'];
$sessionRevision = @$_SERVER['HTTP_WEBODF_SESSION_REVISION']; if (!$sessionID){
$content = fopen('php://input','r'); throw new \Exception('Session id can not be empty');
if ($sessionID && $content){ }
$memberId = @$_SERVER['HTTP_WEBODF_MEMBER_ID'];
$sessionRevision = @$_SERVER['HTTP_WEBODF_SESSION_REVISION'];
$content = fopen('php://input','r');
if (!$content){
throw new \Exception('New conent missing');
}
$session = Session::getSession($sessionID); $session = Session::getSession($sessionID);
if (!$session){
throw new \Exception('Session does not exist');
}
$fileInfo = \OC\Files\Cache\Cache::getById($session['file_id']); $fileInfo = \OC\Files\Cache\Cache::getById($session['file_id']);
$path = $fileInfo[1]; $path = $fileInfo[1];
$view = new \OC\Files\View('/' . $session['owner']); $view = new \OC\Files\View('/' . $session['owner']);
$canWrite = ($view->file_exists($path) && $view->isUpdatable($path)) || $view->isCreatable($path); $isWritable = ($view->file_exists($path) && $view->isUpdatable($path)) || $view->isCreatable($path);
if ($canWrite){ if (!$isWritable){
$view->file_put_contents($path, $content); throw new \Exception('Document does not exist or is not writable for this user');
} else {
// TODO: report an error, break a plate, burn a house, conquer the galaxy
} }
$view->file_put_contents($path, $content);
\OCP\JSON::success();
exit();
} catch (\Exception $e){
Helper::warnLog('Saving failed. Reason:' . $e->getMessage());
\OCP\JSON::error(array('message'=>$e->getMessage()));
exit();
} }
} }

Loading…
Cancel
Save