Save as a new file if old was deleted. Fixes #188

This commit is contained in:
Victor Dubiniuk 2014-03-18 00:35:09 +03:00
parent 6fb03c35c7
commit 6badc5c105
2 changed files with 24 additions and 12 deletions

View File

@ -83,18 +83,22 @@ class SessionController extends Controller{
throw new \Exception('Session does not exist'); throw new \Exception('Session does not exist');
} }
$sessionData = $session->getData(); $sessionData = $session->getData();
try {
$file = new File($sessionData['file_id']); $file = new File($sessionData['file_id']);
if (!$file->isPublicShare()){ if (!$file->isPublicShare()){
self::preDispatch(); self::preDispatch();
} else { } else {
self::preDispatchGuest(); self::preDispatchGuest();
} }
list($view, $path) = $file->getOwnerViewAndPath(); list($view, $path) = $file->getOwnerViewAndPath();
} catch (\Exception $e){
//File was deleted or unshared. We need to save content as new file anyway
//Sorry, but for guests it would be lost :(
$uid = self::preDispatch();
$view = new \OC\Files\View('/' . $uid . '/files');
$isWritable = ($view->file_exists($path) && $view->isUpdatable($path)) || $view->isCreatable($path); $dir = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '');
if (!$isWritable){ $path = Helper::getNewFileName($view, $dir . 'New Document.odt');
throw new \Exception($path . ' does not exist or is not writable for user ' . $uid);
} }
$member = new Db_Member(); $member = new Db_Member();

View File

@ -81,6 +81,14 @@ class Storage {
return; return;
} }
$member = new Db_Member();
$sessionMembers = $member->getCollectionBy('es_id', $session['es_id']);
foreach ($sessionMembers as $memberData){
if (intval($memberData['status'])===Db_Member::MEMBER_STATUS_ACTIVE){
return;
}
}
Db_Session::cleanUp($session['es_id']); Db_Session::cleanUp($session['es_id']);
} }