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()));
// 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
$this->dbConn->beginTransaction();
$qb->execute();
$id = $this->dbConn->lastInsertId('*PREFIX*share');
$qb->executeUpdate();
// Now fetch the inserted share and create a complete share object
$qb = $this->dbConn->getQueryBuilder();
$qb->select('*')
->from('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
// Update mandatory data
$id = $qb->getLastInsertId();
$share->setId($id);
$share->setProviderId($this->identifier());
$cursor = $qb->execute();
$data = $cursor->fetch();
$this->dbConn->commit();
$cursor->closeCursor();
if ($data === false) {
throw new ShareNotFound();
}
$shareTime = new \DateTime();
$shareTime->setTimestamp($time);
$share->setShareTime($shareTime);
$mailSendValue = $share->getMailSend();
$data['mail_send'] = ($mailSendValue === null) ? true : $mailSendValue;
$share->setMailSend(($mailSendValue === null) ? true : $mailSendValue);
$share = $this->createShare($data);
return $share;
}

View File

@ -28,4 +28,18 @@ namespace OCP\Share\Exceptions;
* @since 9.0.0
*/
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);
}
}