@@ -153,7 +153,23 @@ public function rmdir(string $path): bool {
153153 return false ;
154154 }
155155
156- return $ this ->rmObjects ($ entry );
156+ $ result = $ this ->rmObjects ($ entry );
157+ if ($ result ) {
158+ $ this ->removeFromCache ($ entry );
159+ }
160+ return $ result ;
161+ }
162+
163+ /**
164+ * Remove an item from cache and propagate the change to the parent folders.
165+ *
166+ * Similar logic to the `Updater` but done in-storage because we have the correct info to avoid expensive
167+ * folder size calculations.
168+ */
169+ private function removeFromCache (ICacheEntry $ entry ): void {
170+ $ this ->cache ->remove ($ entry ->getId ());
171+ $ this ->getUpdater ()->correctParentStorageMtime ($ entry ->getPath ());
172+ $ this ->propagator ->propagateChange ($ entry ->getPath (), time (), -$ entry ->getSize ());
157173 }
158174
159175 private function rmObjects (ICacheEntry $ entry ): bool {
@@ -180,15 +196,21 @@ private function rmObjects(ICacheEntry $entry): bool {
180196 public function unlink (string $ path ): bool {
181197 $ path = $ this ->normalizePath ($ path );
182198 $ entry = $ this ->getCache ()->get ($ path );
199+ $ result = false ;
183200
184201 if ($ entry instanceof ICacheEntry) {
185202 if ($ entry ->getMimeType () === ICacheEntry::DIRECTORY_MIMETYPE ) {
186- return $ this ->rmObjects ($ entry );
203+ $ result = $ this ->rmObjects ($ entry );
187204 } else {
188- return $ this ->rmObject ($ entry );
205+ $ result = $ this ->rmObject ($ entry );
189206 }
190207 }
191- return false ;
208+
209+ if ($ result ) {
210+ $ this ->removeFromCache ($ entry );
211+ }
212+
213+ return $ result ;
192214 }
193215
194216 public function rmObject (ICacheEntry $ entry ): bool {
0 commit comments