]> source.dussan.org Git - nextcloud-server.git/commitdiff
Harden appdata putcontent 14989/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Mon, 8 Apr 2019 11:21:46 +0000 (13:21 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Mon, 8 Apr 2019 11:22:00 +0000 (13:22 +0200)
If for whatever reason appdata got into a strange state this will at
least propegate up and not make it do boom the next run.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
lib/private/Files/SimpleFS/SimpleFile.php
lib/public/Files/SimpleFS/ISimpleFile.php

index 7b83e9372f7a24978b6a755d6ed6d05877254fa9..9c9ca10650caf7c9c81d4f8e98238285c59bbbf5 100644 (file)
@@ -99,9 +99,14 @@ class SimpleFile implements ISimpleFile  {
         *
         * @param string|resource $data
         * @throws NotPermittedException
+        * @throws NotFoundException
         */
        public function putContent($data) {
-               $this->file->putContent($data);
+               try {
+                       return $this->file->putContent($data);
+               } catch (NotFoundException $e) {
+                       $this->checkFile();
+               }
        }
 
        /**
@@ -119,7 +124,11 @@ class SimpleFile implements ISimpleFile  {
 
                while ($cur->stat() === false) {
                        $parent = $cur->getParent();
-                       $cur->delete();
+                       try {
+                               $cur->delete();
+                       } catch (NotFoundException $e) {
+                               // Just continue then
+                       }
                        $cur = $parent;
                }
 
index a3cd3245cc7bc7d636490d850d037e42d1966a8c..b00f5c482c641aab2314be001d82cd438cc6ae59 100644 (file)
@@ -80,6 +80,7 @@ interface ISimpleFile {
         *
         * @param string|resource $data
         * @throws NotPermittedException
+        * @throws NotFoundException
         * @since 11.0.0
         */
        public function putContent($data);