diff --git a/apps/files_external/lib/Command/Notify.php b/apps/files_external/lib/Command/Notify.php
index a55b16a45c49c14538f5e1980c0ed7db7b178e97..55d7eef58231d26a1239209feb0732a5ebe66f1f 100644
--- a/apps/files_external/lib/Command/Notify.php
+++ b/apps/files_external/lib/Command/Notify.php
@@ -184,15 +184,20 @@ class Notify extends Base {
 		$storage->file_put_contents('/.nc_test_file.txt', 'test content');
 		$storage->mkdir('/.nc_test_folder');
 		$storage->file_put_contents('/.nc_test_folder/subfile.txt', 'test content');
+
+		usleep(100 * 1000); //time for all changes to be processed
+		$changes = $notifyHandler->getChanges();
+
 		$storage->unlink('/.nc_test_file.txt');
 		$storage->unlink('/.nc_test_folder/subfile.txt');
 		$storage->rmdir('/.nc_test_folder');
+
 		usleep(100 * 1000); //time for all changes to be processed
+		$notifyHandler->getChanges(); // flush
 
 		$foundRootChange = false;
 		$foundSubfolderChange = false;
 
-		$changes = $notifyHandler->getChanges();
 		foreach ($changes as $change) {
 			if ($change->getPath() === '/.nc_test_file.txt') {
 				$foundRootChange = true;