]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check for free space on touch 15772/head
authorJulius Härtl <jus@bitgrid.net>
Tue, 28 May 2019 11:05:20 +0000 (13:05 +0200)
committerBackportbot <backportbot-noreply@rullzer.com>
Tue, 28 May 2019 13:04:49 +0000 (13:04 +0000)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
lib/private/Files/Node/Folder.php
lib/private/Files/Storage/Wrapper/Quota.php
tests/lib/Files/Storage/Wrapper/QuotaTest.php

index ebf67e47a2173ba22295ea7317ae7a57bed6ebad..1e9088a7c19a03875c66f67b1667715df1fd6391 100644 (file)
@@ -181,14 +181,15 @@ class Folder extends Node implements \OCP\Files\Folder {
                        $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');
        }
 
        /**
index 4cbe9189593627eafb9b450cf86749d82d729370..492b5aba4361e714859820ec2fd5ea0821d2bc0f 100644 (file)
@@ -209,4 +209,14 @@ class Quota extends Wrapper {
 
                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);
+       }
+
 }
index adfd60d0532d8bcc3a5413e64a08da761415342d..0b80467fcc4895b7a722033479cbaacbcda1fbc5 100644 (file)
@@ -213,4 +213,9 @@ class QuotaTest extends \Test\Files\Storage\Storage {
                $instance = $this->getLimitedStorage(0.0);
                $this->assertFalse($instance->mkdir('foobar'));
        }
+
+       public function testNoTouchQuotaZero() {
+               $instance = $this->getLimitedStorage(0.0);
+               $this->assertFalse($instance->touch('foobar'));
+       }
 }