diff options
author | Anna Larch <anna@nextcloud.com> | 2022-10-02 10:44:15 +0200 |
---|---|---|
committer | Anna Larch <anna@nextcloud.com> | 2023-02-13 15:00:23 +0100 |
commit | 5b6a0affd01f2093a4e2fdbbc916ea8935f65166 (patch) | |
tree | 6edb9844f5a7f9c1fee0d337eacdf8c5faf7d3e1 /apps/dav/lib | |
parent | dcfc96f0cce0a4bc50c4c989464fbbb275ec16b0 (diff) | |
download | nextcloud-server-5b6a0affd01f2093a4e2fdbbc916ea8935f65166.tar.gz nextcloud-server-5b6a0affd01f2093a4e2fdbbc916ea8935f65166.zip |
Allow reimporting prev. deleted items by deleting trashbin item
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/CalDAV/CalDavBackend.php | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 51eb505124e..6ab4f054fef 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1223,17 +1223,19 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription } // For a more specific error message we also try to explicitly look up the UID but as a deleted entry $qbDel = $this->db->getQueryBuilder(); - $qbDel->select($qb->func()->count('*')) + $qbDel->select('*') ->from('calendarobjects') ->where($qbDel->expr()->eq('calendarid', $qbDel->createNamedParameter($calendarId))) ->andWhere($qbDel->expr()->eq('uid', $qbDel->createNamedParameter($extraData['uid']))) ->andWhere($qbDel->expr()->eq('calendartype', $qbDel->createNamedParameter($calendarType))) ->andWhere($qbDel->expr()->isNotNull('deleted_at')); $result = $qbDel->executeQuery(); - $count = (int) $result->fetchOne(); + $found = $result->fetch(); $result->closeCursor(); - if ($count !== 0) { - throw new BadRequest('Deleted calendar object with uid already exists in this calendar collection.'); + if ($found !== false) { + // the object existed previously but has been deleted + // remove the trashbin entry and continue as if it was a new object + $this->deleteCalendarObject($calendarId, $found['uri']); } $query = $this->db->getQueryBuilder(); |