summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/dav/lib/Connector/Sabre/File.php8
-rw-r--r--apps/dav/lib/Upload/ChunkingPlugin.php5
-rw-r--r--lib/private/Collaboration/Collaborators/MailPlugin.php19
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreStorage.php4
-rw-r--r--lib/private/Template/JSCombiner.php9
-rw-r--r--tests/lib/Collaboration/Collaborators/MailPluginTest.php129
-rw-r--r--tests/lib/Template/JSCombinerTest.php17
7 files changed, 161 insertions, 30 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index 597e6ebef90..6a467e9eff2 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -144,6 +144,8 @@ class File extends Node implements IFile {
} else {
// upload file directly as the final path
$partFilePath = $this->path;
+
+ $this->emitPreHooks($exists);
}
// the part file and target file might be on a different storage in case of a single file storage (e.g. single file share)
@@ -188,11 +190,7 @@ class File extends Node implements IFile {
try {
$view = \OC\Files\Filesystem::getView();
- if ($view) {
- $run = $this->emitPreHooks($exists);
- } else {
- $run = true;
- }
+ $run = ($view && $needsPartFile) ? $this->emitPreHooks($exists) : true;
try {
$this->changeLock(ILockingProvider::LOCK_EXCLUSIVE);
diff --git a/apps/dav/lib/Upload/ChunkingPlugin.php b/apps/dav/lib/Upload/ChunkingPlugin.php
index 5768f53c2b4..858129dd598 100644
--- a/apps/dav/lib/Upload/ChunkingPlugin.php
+++ b/apps/dav/lib/Upload/ChunkingPlugin.php
@@ -99,7 +99,10 @@ class ChunkingPlugin extends ServerPlugin {
return;
}
$actualSize = $this->sourceNode->getSize();
- if ((int)$expectedSize !== $actualSize) {
+
+ // casted to string because cast to float cause equality for non equal numbers
+ // and integer has the problem of limited size on 32 bit systems
+ if ((string)$expectedSize !== (string)$actualSize) {
throw new BadRequest("Chunks on server do not sum up to $expectedSize but to $actualSize bytes");
}
}
diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php
index 464b6702066..075689a068e 100644
--- a/lib/private/Collaboration/Collaborators/MailPlugin.php
+++ b/lib/private/Collaboration/Collaborators/MailPlugin.php
@@ -73,7 +73,7 @@ class MailPlugin implements ISearchPlugin {
* @since 13.0.0
*/
public function search($search, $limit, $offset, ISearchResult $searchResult) {
- $result = ['wide' => [], 'exact' => []];
+ $result = $userResults = ['wide' => [], 'exact' => []];
$userType = new SearchResultType('users');
$emailType = new SearchResultType('emails');
@@ -136,14 +136,13 @@ class MailPlugin implements ISearchPlugin {
}
if (!$this->isCurrentUser($cloud) && !$searchResult->hasResult($userType, $cloud->getUser())) {
- $singleResult = [[
+ $userResults['wide'][] = [
'label' => $contact['FN'] . " ($emailAddress)",
'value' => [
'shareType' => Share::SHARE_TYPE_USER,
'shareWith' => $cloud->getUser(),
- ]],
+ ],
];
- $searchResult->addResultSet($userType, $singleResult, []);
}
}
continue;
@@ -173,12 +172,19 @@ class MailPlugin implements ISearchPlugin {
}
}
+ $reachedEnd = true;
if (!$this->shareeEnumeration) {
$result['wide'] = [];
+ $userResults['wide'] = [];
} else {
+ $reachedEnd = (count($result['wide']) < $offset + $limit) &&
+ (count($userResults['wide']) < $offset + $limit);
+
$result['wide'] = array_slice($result['wide'], $offset, $limit);
+ $userResults['wide'] = array_slice($userResults['wide'], $offset, $limit);
}
+
if (!$searchResult->hasExactIdMatch($emailType) && filter_var($search, FILTER_VALIDATE_EMAIL)) {
$result['exact'][] = [
'label' => $search,
@@ -189,9 +195,12 @@ class MailPlugin implements ISearchPlugin {
];
}
+ if (!empty($userResults['wide'])) {
+ $searchResult->addResultSet($userType, $userResults['wide'], []);
+ }
$searchResult->addResultSet($emailType, $result['wide'], $result['exact']);
- return true;
+ return !$reachedEnd;
}
public function isCurrentUser(ICloudId $cloud) {
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
index acb8d670780..4c540071471 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
@@ -424,4 +424,8 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
public function hasUpdated($path, $time) {
return false;
}
+
+ public function needsPartFile() {
+ return false;
+ }
}
diff --git a/lib/private/Template/JSCombiner.php b/lib/private/Template/JSCombiner.php
index c5adcee6854..bc548c22fd0 100644
--- a/lib/private/Template/JSCombiner.php
+++ b/lib/private/Template/JSCombiner.php
@@ -104,13 +104,20 @@ class JSCombiner {
* @return bool
*/
protected function isCached($fileName, ISimpleFolder $folder) {
- $fileName = str_replace('.json', '.js', $fileName) . '.deps';
+ $fileName = str_replace('.json', '.js', $fileName);
+
+ if (!$folder->fileExists($fileName)) {
+ return false;
+ }
+
+ $fileName = $fileName . '.deps';
try {
$deps = $this->depsCache->get($folder->getName() . '-' . $fileName);
if ($deps === null || $deps === '') {
$depFile = $folder->getFile($fileName);
$deps = $depFile->getContent();
}
+
// check again
if ($deps === null || $deps === '') {
$this->logger->info('JSCombiner: deps file empty: ' . $fileName);
diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
index 9c4836c2eb3..775941bd440 100644
--- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
@@ -32,6 +32,7 @@ use OCP\Contacts\IManager;
use OCP\Federation\ICloudIdManager;
use OCP\IConfig;
use OCP\IGroupManager;
+use OCP\IUser;
use OCP\IUserSession;
use OCP\Share;
use Test\TestCase;
@@ -98,6 +99,12 @@ class MailPluginTest extends TestCase {
$this->instantiatePlugin();
+ $currentUser = $this->createMock(IUser::class);
+ $currentUser->method('getUID')
+ ->willReturn('current');
+ $this->userSession->method('getUser')
+ ->willReturn($currentUser);
+
$this->contactsManager->expects($this->any())
->method('search')
->with($searchTerm, ['EMAIL', 'FN'])
@@ -113,15 +120,15 @@ class MailPluginTest extends TestCase {
public function dataGetEmail() {
return [
- ['test', [], true, ['emails' => [], 'exact' => ['emails' => []]], false, true],
- ['test', [], false, ['emails' => [], 'exact' => ['emails' => []]], false, true],
+ ['test', [], true, ['emails' => [], 'exact' => ['emails' => []]], false, false],
+ ['test', [], false, ['emails' => [], 'exact' => ['emails' => []]], false, false],
[
'test@remote.com',
[],
true,
['emails' => [], 'exact' => ['emails' => [['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
- true,
+ false,
],
[ // no valid email address
'test@remote',
@@ -129,7 +136,7 @@ class MailPluginTest extends TestCase {
true,
['emails' => [], 'exact' => ['emails' => []]],
false,
- true,
+ false,
],
[
'test@remote.com',
@@ -137,7 +144,7 @@ class MailPluginTest extends TestCase {
false,
['emails' => [], 'exact' => ['emails' => [['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
- true,
+ false,
],
[
'test',
@@ -160,7 +167,7 @@ class MailPluginTest extends TestCase {
true,
['emails' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => []]],
false,
- true,
+ false,
],
[
'test',
@@ -183,7 +190,7 @@ class MailPluginTest extends TestCase {
false,
['emails' => [], 'exact' => ['emails' => []]],
false,
- true,
+ false,
],
[
'test@remote.com',
@@ -206,7 +213,7 @@ class MailPluginTest extends TestCase {
true,
['emails' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => [['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
- true,
+ false,
],
[
'test@remote.com',
@@ -229,7 +236,7 @@ class MailPluginTest extends TestCase {
false,
['emails' => [], 'exact' => ['emails' => [['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
- true,
+ false,
],
[
'username@localhost',
@@ -252,7 +259,7 @@ class MailPluginTest extends TestCase {
true,
['emails' => [], 'exact' => ['emails' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
true,
- true,
+ false,
],
[
'username@localhost',
@@ -275,7 +282,7 @@ class MailPluginTest extends TestCase {
false,
['emails' => [], 'exact' => ['emails' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
true,
- true,
+ false,
],
// contact with space
[
@@ -299,7 +306,7 @@ class MailPluginTest extends TestCase {
false,
['emails' => [], 'exact' => ['emails' => [['label' => 'User Name @ Localhost (user name@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'user name@localhost']]]]],
true,
- true,
+ false,
],
// remote with space, no contact
[
@@ -323,7 +330,7 @@ class MailPluginTest extends TestCase {
false,
['emails' => [], 'exact' => ['emails' => []]],
false,
- true,
+ false,
],
// Local user found by email
[
@@ -337,10 +344,96 @@ class MailPluginTest extends TestCase {
]
],
false,
- ['users' => [], 'exact' => ['users' => [['label' => 'User (test@example.com)','value' => ['shareType' => 0, 'shareWith' => 'test'],]]]],
+ ['users' => [], 'exact' => ['users' => [['label' => 'User (test@example.com)','value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test'],]]]],
true,
false,
- ]
+ ],
+ // Current local user found by email => no result
+ [
+ 'test@example.com',
+ [
+ [
+ 'FN' => 'User',
+ 'EMAIL' => ['test@example.com'],
+ 'CLOUD' => ['current@localhost'],
+ 'isLocalSystemBook' => true,
+ ]
+ ],
+ true,
+ ['exact' => []],
+ false,
+ false,
+ ],
+ // Pagination and "more results" for user matches byyyyyyy emails
+ [
+ 'test@example',
+ [
+ [
+ 'FN' => 'User1',
+ 'EMAIL' => ['test@example.com'],
+ 'CLOUD' => ['test1@localhost'],
+ 'isLocalSystemBook' => true,
+ ],
+ [
+ 'FN' => 'User2',
+ 'EMAIL' => ['test@example.de'],
+ 'CLOUD' => ['test2@localhost'],
+ 'isLocalSystemBook' => true,
+ ],
+ [
+ 'FN' => 'User3',
+ 'EMAIL' => ['test@example.org'],
+ 'CLOUD' => ['test3@localhost'],
+ 'isLocalSystemBook' => true,
+ ],
+ [
+ 'FN' => 'User4',
+ 'EMAIL' => ['test@example.net'],
+ 'CLOUD' => ['test4@localhost'],
+ 'isLocalSystemBook' => true,
+ ],
+ ],
+ true,
+ ['users' => [
+ ['label' => 'User1 (test@example.com)', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'User2 (test@example.de)', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ], 'emails' => [], 'exact' => ['users' => [], 'emails' => []]],
+ false,
+ true,
+ ],
+ // Pagination and "more results" for normal emails
+ [
+ 'test@example',
+ [
+ [
+ 'FN' => 'User1',
+ 'EMAIL' => ['test@example.com'],
+ 'CLOUD' => ['test1@localhost'],
+ ],
+ [
+ 'FN' => 'User2',
+ 'EMAIL' => ['test@example.de'],
+ 'CLOUD' => ['test2@localhost'],
+ ],
+ [
+ 'FN' => 'User3',
+ 'EMAIL' => ['test@example.org'],
+ 'CLOUD' => ['test3@localhost'],
+ ],
+ [
+ 'FN' => 'User4',
+ 'EMAIL' => ['test@example.net'],
+ 'CLOUD' => ['test4@localhost'],
+ ],
+ ],
+ true,
+ ['emails' => [
+ ['label' => 'User1 (test@example.com)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@example.com']],
+ ['label' => 'User2 (test@example.de)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@example.de']],
+ ], 'exact' => ['emails' => []]],
+ false,
+ true,
+ ],
];
}
@@ -422,7 +515,7 @@ class MailPluginTest extends TestCase {
],
['users' => [['label' => 'User (test@example.com)','value' => ['shareType' => 0, 'shareWith' => 'test'],]], 'emails' => [], 'exact' => ['emails' => [], 'users' => []]],
false,
- true,
+ false,
[
"currentUser" => ["group1"],
"User" => ["group1"]
@@ -442,7 +535,7 @@ class MailPluginTest extends TestCase {
],
['emails'=> [], 'exact' => ['emails' => []]],
false,
- true,
+ false,
[
"currentUser" => ["group1"],
"User" => ["group2"]
@@ -462,7 +555,7 @@ class MailPluginTest extends TestCase {
],
['emails' => [], 'exact' => ['emails' => [['label' => 'test@example.com', 'value' => ['shareType' => 4,'shareWith' => 'test@example.com']]]]],
false,
- true,
+ false,
[
"currentUser" => ["group1"],
"User" => ["group2"]
diff --git a/tests/lib/Template/JSCombinerTest.php b/tests/lib/Template/JSCombinerTest.php
index d5f7000e0a5..bec88801d6b 100644
--- a/tests/lib/Template/JSCombinerTest.php
+++ b/tests/lib/Template/JSCombinerTest.php
@@ -187,6 +187,10 @@ class JSCombinerTest extends \Test\TestCase {
$fileDeps->expects($this->once())->method('getContent')->willReturn('{}');
+ $folder->method('fileExists')
+ ->with('combine.js')
+ ->willReturn(true);
+
$folder->method('getFile')
->will($this->returnCallback(function($path) use ($file, $fileDeps) {
if ($path === 'combine.js') {
@@ -196,6 +200,7 @@ class JSCombinerTest extends \Test\TestCase {
if ($path === 'combine.js.deps') {
return $fileDeps;
}
+
$this->fail();
}));
@@ -221,6 +226,9 @@ class JSCombinerTest extends \Test\TestCase {
->willReturn($folder);
$folder->method('getName')
->willReturn('awesomeapp');
+ $folder->method('fileExists')
+ ->with('combine.js')
+ ->willReturn(true);
$file = $this->createMock(ISimpleFile::class);
@@ -263,6 +271,9 @@ class JSCombinerTest extends \Test\TestCase {
public function testIsCachedWithNotExistingFile() {
$fileName = 'combine.json';
$folder = $this->createMock(ISimpleFolder::class);
+ $folder->method('fileExists')
+ ->with('combine.js')
+ ->willReturn(true);
$file = $this->createMock(ISimpleFile::class);
$folder->method('getFile')
->with('combine.js.deps')
@@ -278,6 +289,9 @@ class JSCombinerTest extends \Test\TestCase {
public function testIsCachedWithOlderMtime() {
$fileName = 'combine.json';
$folder = $this->createMock(ISimpleFolder::class);
+ $folder->method('fileExists')
+ ->with('combine.js')
+ ->willReturn(true);
$file = $this->createMock(ISimpleFile::class);
$folder->method('getFile')
->with('combine.js.deps')
@@ -293,6 +307,9 @@ class JSCombinerTest extends \Test\TestCase {
public function testIsCachedWithoutContent() {
$fileName = 'combine.json';
$folder = $this->createMock(ISimpleFolder::class);
+ $folder->method('fileExists')
+ ->with('combine.js')
+ ->willReturn(true);
$file = $this->createMock(ISimpleFile::class);
$folder->method('getFile')
->with('combine.js.deps')