Harden appdata putcontent

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>
pull/15000/head
Roeland Jago Douma 2019-04-08 13:21:46 +07:00 committed by Backportbot
parent 3fc462e332
commit dc99cc7eab
2 changed files with 12 additions and 2 deletions

@ -99,9 +99,14 @@ class SimpleFile implements ISimpleFile {
* *
* @param string|resource $data * @param string|resource $data
* @throws NotPermittedException * @throws NotPermittedException
* @throws NotFoundException
*/ */
public function putContent($data) { 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) { while ($cur->stat() === false) {
$parent = $cur->getParent(); $parent = $cur->getParent();
$cur->delete(); try {
$cur->delete();
} catch (NotFoundException $e) {
// Just continue then
}
$cur = $parent; $cur = $parent;
} }

@ -80,6 +80,7 @@ interface ISimpleFile {
* *
* @param string|resource $data * @param string|resource $data
* @throws NotPermittedException * @throws NotPermittedException
* @throws NotFoundException
* @since 11.0.0 * @since 11.0.0
*/ */
public function putContent($data); public function putContent($data);