Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Check for free space on touch
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed May 28, 2019
commit 67dd4b018abde6523c283738411590cf85f5308d
7 changes: 4 additions & 3 deletions lib/private/Files/Node/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,15 @@ public function newFile($path) {
$nonExisting = new NonExistingFile($this->root, $this->view, $fullPath);
$this->root->emit('\OC\Files', 'preWrite', 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);
$this->root->emit('\OC\Files', 'postWrite', array($node));
$this->root->emit('\OC\Files', 'postCreate', array($node));
return $node;
} else {
throw new NotPermittedException('No create permission for path');
}
throw new NotPermittedException('No create permission for path');
}

/**
Expand Down
10 changes: 10 additions & 0 deletions lib/private/Files/Storage/Wrapper/Quota.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,14 @@ public function 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);
}

}
5 changes: 5 additions & 0 deletions tests/lib/Files/Storage/Wrapper/QuotaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,9 @@ public function testNoMkdirQuotaZero() {
$instance = $this->getLimitedStorage(0.0);
$this->assertFalse($instance->mkdir('foobar'));
}

public function testNoTouchQuotaZero() {
$instance = $this->getLimitedStorage(0.0);
$this->assertFalse($instance->touch('foobar'));
}
}