Compare commits

...

3 Commits

Author SHA1 Message Date
John Molakvoæ (skjnldsv) 0cef6fd4e1
Fix sharing creation insert and get
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
2021-04-23 09:12:12 +02:00
John Molakvoæ (skjnldsv) 3612a1097a
Default message for ShareNotFound exception
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
2021-04-22 08:50:17 +02:00
John Molakvoæ (skjnldsv) 3d4929bd57
Add proper message to created share not found
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
2021-04-22 08:50:17 +02:00
2 changed files with 25 additions and 19 deletions

View File

@ -204,32 +204,24 @@ class DefaultShareProvider implements IShareProvider {
$qb->setValue('file_target', $qb->createNamedParameter($share->getTarget())); $qb->setValue('file_target', $qb->createNamedParameter($share->getTarget()));
// Set the time this share was created // Set the time this share was created
$qb->setValue('stime', $qb->createNamedParameter(time())); $time = time();
$qb->setValue('stime', $qb->createNamedParameter($time));
// insert the data and fetch the id of the share // insert the data and fetch the id of the share
$this->dbConn->beginTransaction(); $qb->executeUpdate();
$qb->execute();
$id = $this->dbConn->lastInsertId('*PREFIX*share');
// Now fetch the inserted share and create a complete share object // Update mandatory data
$qb = $this->dbConn->getQueryBuilder(); $id = $qb->getLastInsertId();
$qb->select('*') $share->setId($id);
->from('share') $share->setProviderId($this->identifier());
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
$cursor = $qb->execute(); $shareTime = new \DateTime();
$data = $cursor->fetch(); $shareTime->setTimestamp($time);
$this->dbConn->commit(); $share->setShareTime($shareTime);
$cursor->closeCursor();
if ($data === false) {
throw new ShareNotFound();
}
$mailSendValue = $share->getMailSend(); $mailSendValue = $share->getMailSend();
$data['mail_send'] = ($mailSendValue === null) ? true : $mailSendValue; $share->setMailSend(($mailSendValue === null) ? true : $mailSendValue);
$share = $this->createShare($data);
return $share; return $share;
} }

View File

@ -28,4 +28,18 @@ namespace OCP\Share\Exceptions;
* @since 9.0.0 * @since 9.0.0
*/ */
class ShareNotFound extends GenericShareException { class ShareNotFound extends GenericShareException {
/**
* @param string $message
* @param string $hint
* @param int $code
* @param \Exception|null $previous
* @since 9.0.0
*/
public function __construct($message = '', ...$arguments) {
if (empty($message)) {
$message = 'Share not found';
}
parent::__construct($message, ...$arguments);
}
} }