Only set the default expiration date on share creation
Fixes #19685 The default expiration date should only be set when we create a new share. So if a share is created and the expiration date is unset. And after that the password is updated the expiration date should remain unset.
This commit is contained in:
parent
7e0ddfe0d0
commit
ee65cd0bd8
4 changed files with 21 additions and 2 deletions
|
@ -261,7 +261,7 @@ class Manager implements IManager {
|
|||
}
|
||||
|
||||
// If expiredate is empty set a default one if there is a default
|
||||
if ($expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
|
||||
if ($share->getFullId() === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
|
||||
$expirationDate = new \DateTime();
|
||||
$expirationDate->setTime(0,0,0);
|
||||
$expirationDate->add(new \DateInterval('P'.$this->shareApiLinkDefaultExpireDays().'D'));
|
||||
|
|
|
@ -90,6 +90,9 @@ class Share implements \OCP\Share\IShare {
|
|||
* @inheritdoc
|
||||
*/
|
||||
public function getFullId() {
|
||||
if ($this->providerId === null || $this->id === null) {
|
||||
return null;
|
||||
}
|
||||
return $this->providerId . ':' . $this->id;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ interface IShare {
|
|||
* Get the full share id. This is the <providerid>:<internalid>.
|
||||
* The full id is unique in the system.
|
||||
*
|
||||
* @return string
|
||||
* @return string|null null is returned when the fullId can't be constructed
|
||||
* @since 9.0.0
|
||||
*/
|
||||
public function getFullId();
|
||||
|
|
|
@ -890,6 +890,22 @@ class ManagerTest extends \Test\TestCase {
|
|||
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);
|
||||
}
|
||||
|
||||
public function testValidateExpirationDateExistingShareNoDefault() {
|
||||
$share = $this->manager->newShare();
|
||||
|
||||
$share->setId('42')->setProviderId('foo');
|
||||
|
||||
$this->config->method('getAppValue')
|
||||
->will($this->returnValueMap([
|
||||
['core', 'shareapi_default_expire_date', 'no', 'yes'],
|
||||
['core', 'shareapi_expire_after_n_days', '7', '6'],
|
||||
]));
|
||||
|
||||
$this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);
|
||||
|
||||
$this->assertEquals(null, $share->getExpirationDate());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Only sharing with group members is allowed
|
||||
|
|
Loading…
Reference in a new issue