Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable28] Ci fixes #48213

Merged
merged 23 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3c7bb63
fix: Drop unnecessary exit
artonge Sep 17, 2024
fe8ac42
fix: get source file before moving the cache item in objectstore move…
icewind1991 Sep 18, 2024
e794d04
fix: create intermediate directories for objectstore moveFromStorage
icewind1991 Sep 18, 2024
e0f7dec
fix: cleanup objectstore file_put_content
icewind1991 Sep 18, 2024
0dacf09
fix: fix object store id for test object store
icewind1991 Sep 18, 2024
78637be
fix: verify that parent exists in cache when inserting
icewind1991 Sep 18, 2024
f1df40f
test: fix incorrect ltrim usage in test
icewind1991 Sep 18, 2024
6421581
fix: ensure parent folder exists when writing a file to object storage
icewind1991 Sep 18, 2024
b8464ef
test: put parent items into cache in tests
icewind1991 Sep 18, 2024
717b303
test: fix service overwrite in PartFileInRootUploadTest
icewind1991 Sep 18, 2024
1df9f6e
test: fix ShareAPIControllerTest.php
icewind1991 Sep 18, 2024
5b7c43f
test: fix trashbin StorageTest
icewind1991 Sep 18, 2024
d3f2e39
test: fix ShareControllerTest.php
icewind1991 Sep 18, 2024
835e14e
fix: Override start method of \Sabre\DAV\Server to remove exception o…
artonge Sep 18, 2024
ec0ff3d
fix(tests): Fix Folder tests
come-nc Sep 17, 2024
0d543d1
fix: Prevent duplicate creation of print_exception function
artonge Sep 18, 2024
1eb9351
fix: fix shared storage test
icewind1991 Sep 19, 2024
5cbd4c0
fix: fix trashbin move with object store
icewind1991 Sep 19, 2024
5d36da3
fix: ensure source folder is removed from cache when moving to object…
icewind1991 Sep 20, 2024
99d62bf
fix: preserve fileid when moving from objectstore to non-objectstore
icewind1991 Sep 25, 2024
49a756b
fix: rework move into object store to better preserve fileids
icewind1991 Sep 26, 2024
2a27a41
fix(tests): UserManager constructor arguments
artonge Oct 1, 2024
821ce4d
fix: improve moving object store items to trashbin
icewind1991 Sep 19, 2024
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
23 changes: 23 additions & 0 deletions apps/dav/lib/Connector/Sabre/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,27 @@ public function __construct($treeOrNode = null) {
self::$exposeVersion = false;
$this->enablePropfindDepthInfinity = true;
}

// Copied from 3rdparty/sabre/dav/lib/DAV/Server.php
// Should be them exact same without the exception output.
public function start(): void {
try {
// If nginx (pre-1.2) is used as a proxy server, and SabreDAV as an
// origin, we must make sure we send back HTTP/1.0 if this was
// requested.
// This is mainly because nginx doesn't support Chunked Transfer
// Encoding, and this forces the webserver SabreDAV is running on,
// to buffer entire responses to calculate Content-Length.
$this->httpResponse->setHTTPVersion($this->httpRequest->getHTTPVersion());

// Setting the base url
$this->httpRequest->setBaseUrl($this->getBaseUri());
$this->invokeMethod($this->httpRequest, $this->httpResponse);
} catch (\Throwable $e) {
try {
$this->emit('exception', [$e]);
} catch (\Exception $ignore) {
}
}
}
}
1 change: 0 additions & 1 deletion apps/dav/lib/Files/ErrorPagePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public function generateBody(\Throwable $ex, int $httpCode): mixed {
*/
public function sendResponse() {
$this->server->sapi->sendResponse($this->server->httpResponse);
exit();
}

private function acceptHtml(): bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;

use OC\AllConfig;
use OCP\IConfig;

/**
Expand All @@ -49,7 +50,7 @@ protected function setUp(): void {
return $config->getSystemValue($key, $default);
}
});
$this->overwriteService('AllConfig', $mockConfig);
$this->overwriteService(AllConfig::class, $mockConfig);
parent::setUp();
}

Expand Down
46 changes: 45 additions & 1 deletion apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ public function dataGetShare() {

$parentFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
$parentFolder->method('getId')->willReturn(3);
$mountPoint = $this->createMock(IMountPoint::class);
$mountPoint->method('getMountType')->willReturn('');

$file = $this->getMockBuilder('OCP\Files\File')->getMock();
$file->method('getId')->willReturn(1);
Expand All @@ -559,6 +561,7 @@ public function dataGetShare() {
$file->method('getSize')->willReturn(123465);
$file->method('getMTime')->willReturn(1234567890);
$file->method('getMimeType')->willReturn('myMimeType');
$file->method('getMountPoint')->willReturn($mountPoint);

$folder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
$folder->method('getId')->willReturn(2);
Expand All @@ -568,6 +571,7 @@ public function dataGetShare() {
$folder->method('getSize')->willReturn(123465);
$folder->method('getMTime')->willReturn(1234567890);
$folder->method('getMimeType')->willReturn('myFolderMimeType');
$folder->method('getMountPoint')->willReturn($mountPoint);

[$shareAttributes, $shareAttributesReturnJson] = $this->mockShareAttributes();

Expand Down Expand Up @@ -623,6 +627,9 @@ public function dataGetShare() {
'item_size' => 123465,
'item_mtime' => 1234567890,
'attributes' => null,
'item_permissions' => 4,
'is-mount-root' => false,
'mount-type' => '',
];
$data[] = [$share, $expected];

Expand Down Expand Up @@ -677,6 +684,9 @@ public function dataGetShare() {
'item_size' => 123465,
'item_mtime' => 1234567890,
'attributes' => null,
'item_permissions' => 4,
'is-mount-root' => false,
'mount-type' => '',
];
$data[] = [$share, $expected];

Expand Down Expand Up @@ -737,6 +747,9 @@ public function dataGetShare() {
'item_size' => 123465,
'item_mtime' => 1234567890,
'attributes' => null,
'item_permissions' => 4,
'is-mount-root' => false,
'mount-type' => '',
];
$data[] = [$share, $expected];

Expand Down Expand Up @@ -3727,6 +3740,12 @@ public function dataFormatShare() {
$folder->method('getMimeType')->willReturn('myFolderMimeType');
$fileWithPreview->method('getMimeType')->willReturn('mimeWithPreview');

$mountPoint = $this->createMock(IMountPoint::class);
$mountPoint->method('getMountType')->willReturn('');
$file->method('getMountPoint')->willReturn($mountPoint);
$folder->method('getMountPoint')->willReturn($mountPoint);
$fileWithPreview->method('getMountPoint')->willReturn($mountPoint);

$file->method('getPath')->willReturn('file');
$folder->method('getPath')->willReturn('folder');
$fileWithPreview->method('getPath')->willReturn('fileWithPreview');
Expand Down Expand Up @@ -3824,6 +3843,9 @@ public function dataFormatShare() {
'item_size' => 123456,
'item_mtime' => 1234567890,
'attributes' => '[{"scope":"permissions","key":"download","enabled":true}]',
'item_permissions' => 1,
'is-mount-root' => false,
'mount-type' => '',
], $share, [], false
];
// User backend up
Expand Down Expand Up @@ -3863,6 +3885,9 @@ public function dataFormatShare() {
'item_size' => 123456,
'item_mtime' => 1234567890,
'attributes' => '[{"scope":"permissions","key":"download","enabled":true}]',
'item_permissions' => 1,
'is-mount-root' => false,
'mount-type' => '',
], $share, [
['owner', $owner],
['initiator', $initiator],
Expand Down Expand Up @@ -3920,6 +3945,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -3973,6 +3999,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 11,
], $share, [], false
];

Expand Down Expand Up @@ -4027,6 +4054,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4078,6 +4106,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4136,6 +4165,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4194,6 +4224,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4246,6 +4277,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4298,6 +4330,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4353,6 +4386,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4405,6 +4439,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4457,6 +4492,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4526,6 +4562,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4581,6 +4618,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4634,6 +4672,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 11,
], $share, [], false
];

Expand Down Expand Up @@ -4798,6 +4837,7 @@ public function dataFormatRoomShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, false, []
];

Expand Down Expand Up @@ -4849,6 +4889,7 @@ public function dataFormatRoomShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 9,
], $share, true, [
'share_with_displayname' => 'recipientRoomName'
]
Expand Down Expand Up @@ -4888,11 +4929,14 @@ public function testFormatRoomShare(array $expects, \OCP\Share\IShare $share, bo
->willReturn(true);

$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
->setMethods(['formatShare'])
->setMethods(['formatShare', 'canAccessShare'])
->getMock();
$helper->method('formatShare')
->with($share)
->willReturn($formatShareByHelper);
$helper->method('canAccessShare')
->with($share)
->willReturn(true);

$this->serverContainer->method('get')
->with('\OCA\Talk\Share\Helper\ShareAPIController')
Expand Down
3 changes: 2 additions & 1 deletion apps/files_sharing/tests/Controller/ShareControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ public function testShowShare() {
'previewURL' => 'downloadURL',
'note' => $note,
'hideDownload' => false,
'showgridview' => false
'showgridview' => false,
'filename' => $filename,
];

$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
Expand Down
2 changes: 2 additions & 0 deletions apps/files_sharing/tests/External/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use OCP\Contacts\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudIdManager;
use OCP\Files\Cache\ICacheEntry;
use OCP\ICacheFactory;
use OCP\IURLGenerator;
use OCP\IUserManager;
Expand Down Expand Up @@ -95,6 +96,7 @@ protected function setUp(): void {
$this->storage,
$this->cloudIdManager->getCloudId($this->remoteUser, 'http://example.com/owncloud')
);
$this->cache->insert('', ['size' => 0, 'mtime' => 0, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]);
$this->cache->put(
'test.txt',
[
Expand Down
1 change: 1 addition & 0 deletions apps/files_sharing/tests/SharedStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ public function testMoveFromStorage() {

$sourceStorage = new \OC\Files\Storage\Temporary([]);
$sourceStorage->file_put_contents('foo.txt', 'asd');
$sourceStorage->getScanner()->scan('');

$sharedStorage->moveFromStorage($sourceStorage, 'foo.txt', 'bar.txt');
$this->assertTrue($sharedStorage->file_exists('bar.txt'));
Expand Down
23 changes: 12 additions & 11 deletions apps/files_trashbin/lib/Trashbin.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
use OC\Files\Node\Folder;
use OC\Files\Node\NonExistingFile;
use OC\Files\Node\NonExistingFolder;
use OC\Files\ObjectStore\ObjectStoreStorage;
use OC\Files\View;
use OC_User;
use OCA\Files_Trashbin\AppInfo\Application;
Expand All @@ -67,6 +66,8 @@
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Files\Storage\ILockingStorage;
use OCP\Files\Storage\IStorage;
use OCP\FilesMetadata\IFilesMetadataManager;
use OCP\IConfig;
use OCP\Lock\ILockingProvider;
Expand Down Expand Up @@ -290,11 +291,10 @@ public static function move2trash($file_path, $ownerOnly = false) {
$trashPath = '/files_trashbin/files/' . static::getTrashFilename($filename, $timestamp);
$gotLock = false;

while (!$gotLock) {
do {
/** @var ILockingStorage & IStorage $trashStorage */
[$trashStorage, $trashInternalPath] = $ownerView->resolvePath($trashPath);
try {
/** @var \OC\Files\Storage\Storage $trashStorage */
[$trashStorage, $trashInternalPath] = $ownerView->resolvePath($trashPath);

$trashStorage->acquireLock($trashInternalPath, ILockingProvider::LOCK_EXCLUSIVE, $lockingProvider);
$gotLock = true;
} catch (LockedException $e) {
Expand All @@ -305,7 +305,7 @@ public static function move2trash($file_path, $ownerOnly = false) {

$trashPath = '/files_trashbin/files/' . static::getTrashFilename($filename, $timestamp);
}
}
} while (!$gotLock);

$sourceStorage = $sourceInfo->getStorage();
$sourceInternalPath = $sourceInfo->getInternalPath();
Expand All @@ -319,14 +319,15 @@ public static function move2trash($file_path, $ownerOnly = false) {
return false;
}

$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);

try {
$moveSuccessful = true;

// when moving within the same object store, the cache update done above is enough to move the file
if (!($trashStorage->instanceOfStorage(ObjectStoreStorage::class) && $trashStorage->getId() === $sourceStorage->getId())) {
$trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
$trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
if ($sourceStorage->getCache()->inCache($sourceInternalPath)) {
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
}
if ($trashStorage->getCache()->inCache($sourceInternalPath)) {
Fixed Show fixed Hide fixed
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
Fixed Show fixed Hide fixed
}
} catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
$moveSuccessful = false;
Expand Down
Loading
Loading