Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
use OCP\Server;
use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
use OCP\Share\IShare;
Expand Down Expand Up @@ -804,6 +805,9 @@ public function createShare(
} catch (HintException $e) {
$code = $e->getCode() === 0 ? 403 : $e->getCode();
throw new OCSException($e->getHint(), $code);
} catch (GenericShareException|\InvalidArgumentException $e) {
$this->logger->error($e->getMessage(), ['exception' => $e]);
throw new OCSForbiddenException($e->getMessage(), $e);
} catch (\Exception $e) {
$this->logger->error($e->getMessage(), ['exception' => $e]);
throw new OCSForbiddenException('Failed to create share.', $e);
Expand Down
6 changes: 4 additions & 2 deletions apps/files_sharing/src/mixins/ShareRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
// TODO: remove when ie not supported
import 'url-search-params-polyfill'

import { emit } from '@nextcloud/event-bus'
import { showError } from '@nextcloud/dialogs'
import { generateOcsUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios'

import Share from '../models/Share.js'
import { emit } from '@nextcloud/event-bus'

const shareUrl = generateOcsUrl('apps/files_sharing/api/v1/shares')

Expand Down Expand Up @@ -65,7 +67,7 @@ export default {
} catch (error) {
console.error('Error while creating share', error)
const errorMessage = error?.response?.data?.ocs?.meta?.message
OC.Notification.showTemporary(
showError(
errorMessage ? t('files_sharing', 'Error creating the share: {errorMessage}', { errorMessage }) : t('files_sharing', 'Error creating the share'),
{ type: 'error' },
)
Expand Down
14 changes: 12 additions & 2 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
</NcButton>
<NcButton type="primary"
data-cy-files-sharing-share-editor-action="save"
:disabled="creating"
@click="saveShare">
{{ shareButtonText }}
<template v-if="creating" #icon>
Expand Down Expand Up @@ -899,8 +900,16 @@ export default {
incomingShare.password = this.share.password
}

this.creating = true
const share = await this.addShare(incomingShare)
let share
try {
this.creating = true
share = await this.addShare(incomingShare)
} catch (error) {
this.creating = false
// Error is already handled by ShareRequests mixin
return
}

// ugly hack to make code work - we need the id to be set but at the same time we need to keep values we want to update
this.share._share.id = share.id
await this.queueUpdate(...permissionsAndAttributes)
Expand All @@ -914,6 +923,7 @@ export default {
}
}
}

this.share = share
this.creating = false
this.$emit('add:share', this.share)
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Share20/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ public function testLinkCreateChecksReadOnly() {

public function testPathCreateChecksContainsSharedMount() {
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Path contains files shared with you');
$this->expectExceptionMessage('You cannot share a folder that contains other shares');

$path = $this->createMock(Folder::class);
$path->method('getPath')->willReturn('path');
Expand Down
Loading