4242use  Doctrine \DBAL \Exception \UniqueConstraintViolationException ;
4343use  OCP \DB \QueryBuilder \IQueryBuilder ;
4444use  OCP \Files \Cache \CacheInsertEvent ;
45+ use  OCP \Files \Cache \CacheRemoveEvent ;
4546use  OCP \Files \Cache \CacheUpdateEvent ;
4647use  OCP \Files \Cache \ICache ;
4748use  OCP \Files \Cache \ICacheEntry ;
@@ -284,7 +285,8 @@ public function insert($file, array $data) {
284285		$ data'name ' ] = basename ($ file
285286
286287		[$ values$ extensionValues$ this normalizeData ($ data
287- 		$ values'storage ' ] = $ this getNumericStorageId ();
288+ 		$ storageId$ this getNumericStorageId ();
289+ 		$ values'storage ' ] = $ storageId
288290
289291		try  {
290292			$ builder$ this connection ->getQueryBuilder ();
@@ -308,7 +310,7 @@ public function insert($file, array $data) {
308310					$ queryexecute ();
309311				}
310312
311- 				$ this eventDispatcher ->dispatch (CacheInsertEvent::class, new  CacheInsertEvent ($ this storage , $ file$ fileId
313+ 				$ this eventDispatcher ->dispatch (CacheInsertEvent::class, new  CacheInsertEvent ($ this storage , $ file$ fileId,  $ storageId 
312314				return  $ fileId
313315			}
314316		} catch  (UniqueConstraintViolationException $ e
@@ -399,7 +401,7 @@ public function update($id, array $data) {
399401		$ path$ this getPathById ($ id
400402		// path can still be null if the file doesn't exist 
401403		if  ($ pathnull ) {
402- 			$ this eventDispatcher ->dispatch (CacheUpdateEvent::class, new  CacheUpdateEvent ($ this storage , $ path$ id
404+ 			$ this eventDispatcher ->dispatch (CacheUpdateEvent::class, new  CacheUpdateEvent ($ this storage , $ path$ id,  $ this -> getNumericStorageId () ));
403405		}
404406	}
405407
@@ -536,6 +538,8 @@ public function remove($file) {
536538			if  ($ entrygetMimeType () == FileInfo::MIMETYPE_FOLDER ) {
537539				$ this removeChildren ($ entry
538540			}
541+ 
542+ 			$ this eventDispatcher ->dispatch (CacheRemoveEvent::class, new  CacheRemoveEvent ($ this storage , $ entrygetPath (), $ entrygetId (), $ this getNumericStorageId ()));
539543		}
540544	}
541545
@@ -677,9 +681,17 @@ public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
677681			$ queryexecute ();
678682
679683			$ this connection ->commit ();
684+ 
685+ 			if  ($ sourceCachegetNumericStorageId () !== $ this getNumericStorageId ()) {
686+ 				$ this eventDispatcher ->dispatch (CacheRemoveEvent::class, new  CacheRemoveEvent ($ this storage , $ sourcePath$ sourceId$ sourceCachegetNumericStorageId ()));
687+ 				$ this eventDispatcher ->dispatch (CacheInsertEvent::class, new  CacheInsertEvent ($ this storage , $ targetPath$ sourceId$ this getNumericStorageId ()));
688+ 			} else  {
689+ 				$ this eventDispatcher ->dispatch (CacheUpdateEvent::class, new  CacheUpdateEvent ($ this storage , $ targetPath$ sourceId$ this getNumericStorageId ()));
690+ 			}
680691		} else  {
681692			$ this moveFromCacheFallback ($ sourceCache$ sourcePath$ targetPath
682693		}
694+ 
683695	}
684696
685697	/** 
0 commit comments