Merge pull request #15766 from nextcloud/bugfix/0b-quota-create-backend
Check for free space on touch
This commit is contained in:
commit
abeea8b0b9
|
@ -181,14 +181,15 @@ class Folder extends Node implements \OCP\Files\Folder {
|
||||||
$nonExisting = new NonExistingFile($this->root, $this->view, $fullPath);
|
$nonExisting = new NonExistingFile($this->root, $this->view, $fullPath);
|
||||||
$this->root->emit('\OC\Files', 'preWrite', array($nonExisting));
|
$this->root->emit('\OC\Files', 'preWrite', array($nonExisting));
|
||||||
$this->root->emit('\OC\Files', 'preCreate', array($nonExisting));
|
$this->root->emit('\OC\Files', 'preCreate', array($nonExisting));
|
||||||
$this->view->touch($fullPath);
|
if (!$this->view->touch($fullPath)) {
|
||||||
|
throw new NotPermittedException('Could not create path');
|
||||||
|
}
|
||||||
$node = new File($this->root, $this->view, $fullPath);
|
$node = new File($this->root, $this->view, $fullPath);
|
||||||
$this->root->emit('\OC\Files', 'postWrite', array($node));
|
$this->root->emit('\OC\Files', 'postWrite', array($node));
|
||||||
$this->root->emit('\OC\Files', 'postCreate', array($node));
|
$this->root->emit('\OC\Files', 'postCreate', array($node));
|
||||||
return $node;
|
return $node;
|
||||||
} else {
|
|
||||||
throw new NotPermittedException('No create permission for path');
|
|
||||||
}
|
}
|
||||||
|
throw new NotPermittedException('No create permission for path');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -209,4 +209,14 @@ class Quota extends Wrapper {
|
||||||
|
|
||||||
return parent::mkdir($path);
|
return parent::mkdir($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function touch($path, $mtime = null) {
|
||||||
|
$free = $this->free_space($path);
|
||||||
|
if ($free === 0.0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::touch($path, $mtime);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,4 +213,9 @@ class QuotaTest extends \Test\Files\Storage\Storage {
|
||||||
$instance = $this->getLimitedStorage(0.0);
|
$instance = $this->getLimitedStorage(0.0);
|
||||||
$this->assertFalse($instance->mkdir('foobar'));
|
$this->assertFalse($instance->mkdir('foobar'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNoTouchQuotaZero() {
|
||||||
|
$instance = $this->getLimitedStorage(0.0);
|
||||||
|
$this->assertFalse($instance->touch('foobar'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue