Skip to content

Commit 5d360bd

Browse files
committed
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>
1 parent acba430 commit 5d360bd

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/private/Files/SimpleFS/SimpleFile.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,14 @@ public function getContent() {
9999
*
100100
* @param string|resource $data
101101
* @throws NotPermittedException
102+
* @throws NotFoundException
102103
*/
103104
public function putContent($data) {
104-
$this->file->putContent($data);
105+
try {
106+
return $this->file->putContent($data);
107+
} catch (NotFoundException $e) {
108+
$this->checkFile();
109+
}
105110
}
106111

107112
/**
@@ -119,7 +124,11 @@ private function checkFile() {
119124

120125
while ($cur->stat() === false) {
121126
$parent = $cur->getParent();
122-
$cur->delete();
127+
try {
128+
$cur->delete();
129+
} catch (NotFoundException $e) {
130+
// Just continue then
131+
}
123132
$cur = $parent;
124133
}
125134

lib/public/Files/SimpleFS/ISimpleFile.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public function getContent();
8080
*
8181
* @param string|resource $data
8282
* @throws NotPermittedException
83+
* @throws NotFoundException
8384
* @since 11.0.0
8485
*/
8586
public function putContent($data);

0 commit comments

Comments
 (0)