Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into accept-ocm-to-groups
Browse files Browse the repository at this point in the history
  • Loading branch information
michielbdejong committed Apr 12, 2023
2 parents a1e761e + 01275f7 commit 9a39018
Show file tree
Hide file tree
Showing 1,064 changed files with 17,153 additions and 8,042 deletions.
1 change: 0 additions & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ config = {
"commands": [
"php occ maintenance:singleuser --on",
"php occ encryption:enable",
"php occ encryption:select-encryption-type masterkey --yes",
"php occ encryption:encrypt-all --yes",
"php occ encryption:status",
"php occ maintenance:singleuser --off",
Expand Down
319 changes: 305 additions & 14 deletions CHANGELOG.html

Large diffs are not rendered by default.

368 changes: 358 additions & 10 deletions CHANGELOG.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/dav/l10n/en_GB.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ OC.L10N.register(
"dav",
{
"Contact birthdays" : "Contact birthdays",
"User unknown" : "User unknown",
"User disabled" : "User disabled",
"Personal" : "Personal",
"Contacts" : "Contacts",
Expand Down
1 change: 1 addition & 0 deletions apps/dav/l10n/en_GB.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ "translations": {
"Contact birthdays" : "Contact birthdays",
"User unknown" : "User unknown",
"User disabled" : "User disabled",
"Personal" : "Personal",
"Contacts" : "Contacts",
Expand Down
1 change: 1 addition & 0 deletions apps/dav/l10n/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ OC.L10N.register(
"dav",
{
"Contact birthdays" : "Compleanni dei contatti",
"User unknown" : "Utente sconosciuto",
"User disabled" : "Utente disabilitato",
"Personal" : "Personale",
"Contacts" : "Contatti",
Expand Down
1 change: 1 addition & 0 deletions apps/dav/l10n/it.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ "translations": {
"Contact birthdays" : "Compleanni dei contatti",
"User unknown" : "Utente sconosciuto",
"User disabled" : "Utente disabilitato",
"Personal" : "Personale",
"Contacts" : "Contatti",
Expand Down
1 change: 1 addition & 0 deletions apps/dav/l10n/ko.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ OC.L10N.register(
"dav",
{
"Contact birthdays" : "연락처에 등록된 생일",
"User unknown" : "알 수 없는 사용자",
"User disabled" : "사용자 비활성화됨",
"Personal" : "개인",
"Contacts" : "연락처",
Expand Down
1 change: 1 addition & 0 deletions apps/dav/l10n/ko.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ "translations": {
"Contact birthdays" : "연락처에 등록된 생일",
"User unknown" : "알 수 없는 사용자",
"User disabled" : "사용자 비활성화됨",
"Personal" : "개인",
"Contacts" : "연락처",
Expand Down
12 changes: 12 additions & 0 deletions apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
use Sabre\DAV\Exception\Locked as SabreLocked;
use Sabre\DAV\Exception\NotFound as SabreNotFound;
use Sabre\DAV\Exception\ServiceUnavailable as SabreServiceUnavailable;
use Sabre\DAV\Exception\InsufficientStorage as SabreInsufficientStorage;
use Sabre\DAV\ICollection;
use Sabre\DAV\IFile;
use Sabre\DAV\IMoveTarget;
Expand Down Expand Up @@ -213,6 +214,17 @@ public function createDirectory($name) {
throw new SabreForbidden();
}

$absolutePath = Filesystem::normalizePath($this->fileView->getAbsolutePath($name));
list($targetStorage, $targetInternalPath) = Filesystem::resolvePath($absolutePath);

// We are using == instead of === as the computerFileSize method which is
// used to get the quota may return a float type. Note that the same
// has been observed for the disk_free_space function in local storage
list($used, $free) = $this->getQuotaInfo();
if ($free == 0 && ($targetStorage->instanceOfStorage('\OCP\Files\IHomeStorage') === true)) {
throw new SabreInsufficientStorage('Creation of empty directories is forbidden in case of no available quota');
}

$this->fileView->verifyPath($this->path, $name);
$newPath = $this->path . '/' . $name;
if (!$this->fileView->mkdir($newPath)) {
Expand Down
24 changes: 19 additions & 5 deletions apps/dav/lib/Connector/Sabre/QuotaPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function checkQuota($path, $length = null, $extraSpace = 0) {
if ($length === null) {
$length = $this->getLength();
}
if ($length) {
if ($length !== null) {
list($parentPath, $newName) = \Sabre\Uri\split($path);
if ($parentPath === null) {
$parentPath = '';
Expand All @@ -204,11 +204,25 @@ public function checkQuota($path, $length = null, $extraSpace = 0) {
$path = \rtrim($parentPath, '/') . '/' . $info['name'];
}
$freeSpace = $this->getFreeSpace($path);
if ($freeSpace !== FileInfo::SPACE_UNKNOWN && $freeSpace !== FileInfo::SPACE_UNLIMITED && $length > $freeSpace + $extraSpace) {
if (isset($chunkHandler)) {
$chunkHandler->cleanup();
// workaround to guarantee compatibility on 32-bit systems as otherwise this would cause an int overflow on such systems
// when $freeSpace is above the max supported value. $freeSpace should be a float so we are using the <= 0.0 comparison
if (PHP_INT_SIZE === 4) {
$availableSpace = $freeSpace + $extraSpace;
if ($freeSpace !== FileInfo::SPACE_UNKNOWN && $freeSpace !== FileInfo::SPACE_UNLIMITED && (($length > $availableSpace) || ($availableSpace <= 0.0))) {
if (isset($chunkHandler)) {
$chunkHandler->cleanup();
}
throw new InsufficientStorage();
}
} else {
// freeSpace might be false, or an int. Anyway, make sure that availableSpace will be an int.
$availableSpace = (int) $freeSpace + $extraSpace;
if ($freeSpace !== FileInfo::SPACE_UNKNOWN && $freeSpace !== FileInfo::SPACE_UNLIMITED && (($length > $availableSpace) || ($availableSpace === 0))) {
if (isset($chunkHandler)) {
$chunkHandler->cleanup();
}
throw new InsufficientStorage();
}
throw new InsufficientStorage();
}
}
return true;
Expand Down
18 changes: 8 additions & 10 deletions apps/dav/lib/Meta/MetaFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @author Thomas Müller <[email protected]>
*
* @copyright Copyright (c) 2017, ownCloud GmbH
* @copyright Copyright (c) 2022, ownCloud GmbH
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
Expand All @@ -26,6 +26,7 @@
use OCA\DAV\Files\IProvidesAdditionalHeaders;
use OCA\DAV\Files\IFileNode;
use OCP\Files\IProvidesVersionAuthor;
use OCP\Files\IProvidesVersionTag;
use OCP\Files\Node;
use Sabre\DAV\File;

Expand Down Expand Up @@ -128,24 +129,21 @@ public function getNode() {
}

/**
* @return string
* @inheritdoc
*/
public function getVersionAuthor() : string {
public function getVersionEditedBy() : string {
if ($this->file instanceof IProvidesVersionAuthor) {
return $this->file->getEditedBy();
}
return '';
}

/**
* @return string
* @inheritdoc
*/
public function getVersionAuthorName() : string {
if ($this->file instanceof IProvidesVersionAuthor) {
$uid = $this->file->getEditedBy();
$manager = \OC::$server->getUserManager();
$user = $manager->get($uid);
return $user !== null ? $user->getDisplayName() : '';
public function getVersionTag() : string {
if ($this->file instanceof IProvidesVersionTag) {
return $this->file->getVersionTag();
}
return '';
}
Expand Down
22 changes: 22 additions & 0 deletions apps/dav/lib/Meta/MetaFolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\Node;
use OCP\Files\IProvidesVersionAuthor;
use OCP\Files\IProvidesVersionTag;
use Sabre\DAV\Collection;

/**
Expand Down Expand Up @@ -71,4 +73,24 @@ private function nodeFactory(Node $node) {
}
throw new \InvalidArgumentException();
}

/**
* @inheritdoc
*/
public function getVersionEditedBy() : string {
if ($this->folder instanceof IProvidesVersionAuthor) {
return $this->folder->getEditedBy();
}
return '';
}

/**
* @inheritdoc
*/
public function getVersionTag() : string {
if ($this->folder instanceof IProvidesVersionTag) {
return $this->folder->getVersionTag();
}
return '';
}
}
36 changes: 32 additions & 4 deletions apps/dav/lib/Meta/MetaPlugin.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
/**
* @author Thomas Müller <[email protected]>
* @author Jannik Stehle <[email protected]>
* @author Piotr Mrowczynski <[email protected]>
*
* @copyright Copyright (c) 2019, ownCloud GmbH
* @license AGPL-3.0
Expand Down Expand Up @@ -33,7 +35,9 @@ class MetaPlugin extends ServerPlugin {
public const PATH_FOR_FILEID_PROPERTYNAME = '{http://owncloud.org/ns}meta-path-for-user';

public const VERSION_EDITED_BY_PROPERTYNAME = '{http://owncloud.org/ns}meta-version-edited-by';
public const VERSION_EDITED_BY_PROPERTYNAME_NAME = '{http://owncloud.org/ns}meta-version-edited-by-name';
public const VERSION_EDITED_BY_NAME_PROPERTYNAME = '{http://owncloud.org/ns}meta-version-edited-by-name';
public const VERSION_TAG_PROPERTYNAME = '{http://owncloud.org/ns}meta-version-tag';

/**
* Reference to main server object
*
Expand Down Expand Up @@ -98,12 +102,36 @@ public function handleGetProperties(PropFind $propFind, INode $node) {
$file = \current($files);
return $baseFolder->getRelativePath($file->getPath());
});
$propFind->handle(self::VERSION_EDITED_BY_PROPERTYNAME, function () use ($node) {
return $node->getVersionEditedBy();
});
$propFind->handle(self::VERSION_EDITED_BY_NAME_PROPERTYNAME, function () use ($node) {
$versionEditedBy = $node->getVersionEditedBy();
if (!$versionEditedBy) {
return '';
}
$manager = \OC::$server->getUserManager(); // FIXME: not so good
$user = $manager->get($versionEditedBy);
return $user !== null ? $user->getDisplayName() : '';
});
$propFind->handle(self::VERSION_TAG_PROPERTYNAME, function () use ($node) {
return $node->getVersionTag();
});
} elseif ($node instanceof MetaFile) {
$propFind->handle(self::VERSION_EDITED_BY_PROPERTYNAME, function () use ($node) {
return $node->getVersionAuthor();
return $node->getVersionEditedBy();
});
$propFind->handle(self::VERSION_EDITED_BY_NAME_PROPERTYNAME, function () use ($node) {
$versionEditedBy = $node->getVersionEditedBy();
if (!$versionEditedBy) {
return '';
}
$manager = \OC::$server->getUserManager(); // FIXME: not so good
$user = $manager->get($versionEditedBy);
return $user !== null ? $user->getDisplayName() : '';
});
$propFind->handle(self::VERSION_EDITED_BY_PROPERTYNAME_NAME, function () use ($node) {
return $node->getVersionAuthorName();
$propFind->handle(self::VERSION_TAG_PROPERTYNAME, function () use ($node) {
return $node->getVersionTag();
});
}
}
Expand Down
23 changes: 14 additions & 9 deletions apps/dav/lib/Upload/ChunkLocationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,20 @@ public function __construct(IConfig $config) {
public function getMountsForUser(IUser $user, IStorageFactory $loader) {
$chunkBaseDir = $this->config->getSystemValue('dav.chunk_base_dir', '');
if ($chunkBaseDir === '') {
return [];
// this is needed as otherwise the returned mount point will be in the home storage rather
// than in the "local" external storage and this would cause trouble when applying quota.
$cacheDir = $user->getHome();
return [
new MountPoint(Local::class, '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir . '/uploads'])
];
} else {
$cacheDir = \rtrim($chunkBaseDir, '/') . '/' . $user->getUID();
if (!\file_exists($cacheDir)) {
\mkdir($cacheDir, 0770, true);
}
return [
new MountPoint(Local::class, '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir])
];
}
$cacheDir = \rtrim($chunkBaseDir, '/') . '/' . $user->getUID();
if (!\file_exists($cacheDir)) {
\mkdir($cacheDir, 0770, true);
}

return [
new MountPoint(Local::class, '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir, $loader])
];
}
}
4 changes: 2 additions & 2 deletions apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,8 @@ public function testGetDenormalizedData($expected, $key, $calData) {

public function providesCalDataForGetDenormalizedData() {
return [
'first occurrence before unix epoch starts' => [0, 'firstOccurence', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.5.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:413F269B-B51B-46B1-AFB6-40055C53A4DC\r\nDTSTAMP:20160309T095056Z\r\nDTSTART;VALUE=DATE:16040222\r\nDTEND;VALUE=DATE:16040223\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:SUMMARY\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"],
'no first occurrence because yearly' => [null, 'firstOccurence', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.5.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:413F269B-B51B-46B1-AFB6-40055C53A4DC\r\nDTSTAMP:20160309T095056Z\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:SUMMARY\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"],
'first occurrence before unix epoch starts' => [0, 'firstOccurence', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.5.3//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:413F269B-B51B-46B1-AFB6-40055C53A4DC\r\nDTSTAMP:20160309T095056Z\r\nDTSTART;VALUE=DATE:16040222\r\nDTEND;VALUE=DATE:16040223\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:SUMMARY\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"],
'no first occurrence because yearly' => [null, 'firstOccurence', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.5.3//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:413F269B-B51B-46B1-AFB6-40055C53A4DC\r\nDTSTAMP:20160309T095056Z\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:SUMMARY\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"],
'CLASS:PRIVATE' => [CalDavBackend::CLASSIFICATION_PRIVATE, 'classification', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//dmfs.org//mimedir.icalendar//EN\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nX-LIC-LOCATION:Europe/Berlin\r\nBEGIN:DAYLIGHT\r\nTZOFFSETFROM:+0100\r\nTZOFFSETTO:+0200\r\nTZNAME:CEST\r\nDTSTART:19700329T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\r\nEND:DAYLIGHT\r\nBEGIN:STANDARD\r\nTZOFFSETFROM:+0200\r\nTZOFFSETTO:+0100\r\nTZNAME:CET\r\nDTSTART:19701025T030000\r\nRRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\r\nEND:STANDARD\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nDTSTART;TZID=Europe/Berlin:20160419T130000\r\nSUMMARY:Test\r\nCLASS:PRIVATE\r\nTRANSP:OPAQUE\r\nSTATUS:CONFIRMED\r\nDTEND;TZID=Europe/Berlin:20160419T140000\r\nLAST-MODIFIED:20160419T074202Z\r\nDTSTAMP:20160419T074202Z\r\nCREATED:20160419T074202Z\r\nUID:2e468c48-7860-492e-bc52-92fa0daeeccf.1461051722310\r\nEND:VEVENT\r\nEND:VCALENDAR"],
'CLASS:PUBLIC' => [CalDavBackend::CLASSIFICATION_PUBLIC, 'classification', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//dmfs.org//mimedir.icalendar//EN\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nX-LIC-LOCATION:Europe/Berlin\r\nBEGIN:DAYLIGHT\r\nTZOFFSETFROM:+0100\r\nTZOFFSETTO:+0200\r\nTZNAME:CEST\r\nDTSTART:19700329T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\r\nEND:DAYLIGHT\r\nBEGIN:STANDARD\r\nTZOFFSETFROM:+0200\r\nTZOFFSETTO:+0100\r\nTZNAME:CET\r\nDTSTART:19701025T030000\r\nRRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\r\nEND:STANDARD\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nDTSTART;TZID=Europe/Berlin:20160419T130000\r\nSUMMARY:Test\r\nCLASS:PUBLIC\r\nTRANSP:OPAQUE\r\nSTATUS:CONFIRMED\r\nDTEND;TZID=Europe/Berlin:20160419T140000\r\nLAST-MODIFIED:20160419T074202Z\r\nDTSTAMP:20160419T074202Z\r\nCREATED:20160419T074202Z\r\nUID:2e468c48-7860-492e-bc52-92fa0daeeccf.1461051722310\r\nEND:VEVENT\r\nEND:VCALENDAR"],
'CLASS:CONFIDENTIAL' => [CalDavBackend::CLASSIFICATION_CONFIDENTIAL, 'classification', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//dmfs.org//mimedir.icalendar//EN\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nX-LIC-LOCATION:Europe/Berlin\r\nBEGIN:DAYLIGHT\r\nTZOFFSETFROM:+0100\r\nTZOFFSETTO:+0200\r\nTZNAME:CEST\r\nDTSTART:19700329T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\r\nEND:DAYLIGHT\r\nBEGIN:STANDARD\r\nTZOFFSETFROM:+0200\r\nTZOFFSETTO:+0100\r\nTZNAME:CET\r\nDTSTART:19701025T030000\r\nRRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\r\nEND:STANDARD\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nDTSTART;TZID=Europe/Berlin:20160419T130000\r\nSUMMARY:Test\r\nCLASS:CONFIDENTIAL\r\nTRANSP:OPAQUE\r\nSTATUS:CONFIRMED\r\nDTEND;TZID=Europe/Berlin:20160419T140000\r\nLAST-MODIFIED:20160419T074202Z\r\nDTSTAMP:20160419T074202Z\r\nCREATED:20160419T074202Z\r\nUID:2e468c48-7860-492e-bc52-92fa0daeeccf.1461051722310\r\nEND:VEVENT\r\nEND:VCALENDAR"],
Expand Down
Loading

0 comments on commit 9a39018

Please sign in to comment.