summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-01-06 15:42:43 +0100
committerRobin Appelman <robin@icewind.nl>2017-01-27 10:44:37 +0100
commitc7536f787748a067c250c917d2fdb0d807d73a50 (patch)
tree43b74bdec96ba443d4ce6a92461a10cea649f6a5
parent269747985e1f17ab5cafa0ff02d811433683f7e8 (diff)
downloadnextcloud-server-c7536f787748a067c250c917d2fdb0d807d73a50.tar.gz
nextcloud-server-c7536f787748a067c250c917d2fdb0d807d73a50.zip
switch occ files_external:notify to new notify mechanism
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--apps/files_external/lib/Command/Notify.php22
1 files changed, 12 insertions, 10 deletions
diff --git a/apps/files_external/lib/Command/Notify.php b/apps/files_external/lib/Command/Notify.php
index 913299b59b4..b317f5c0594 100644
--- a/apps/files_external/lib/Command/Notify.php
+++ b/apps/files_external/lib/Command/Notify.php
@@ -27,6 +27,8 @@ use OC\Core\Command\Base;
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\GlobalStoragesService;
+use OCP\Files\Notify\IChange;
+use OCP\Files\Notify\IRenameChange;
use OCP\Files\Storage\INotifyStorage;
use OCP\Files\StorageNotAvailableException;
use OCP\IDBConnection;
@@ -123,14 +125,14 @@ class Notify extends Base {
$verbose = $input->getOption('verbose');
$path = trim($input->getOption('path'), '/');
- $storage->listen($path, function ($type, $path, $renameTarget) use ($mount, $verbose, $output) {
+ $storage->notify($path)->listen(function (IChange $change) use ($mount, $verbose, $output) {
if ($verbose) {
- $this->logUpdate($type, $path, $renameTarget, $output);
+ $this->logUpdate($change, $output);
}
- if ($type == INotifyStorage::NOTIFY_RENAMED) {
- $this->markParentAsOutdated($mount->getId(), $renameTarget);
+ if ($change instanceof IRenameChange) {
+ $this->markParentAsOutdated($mount->getId(), $change->getTargetPath());
}
- $this->markParentAsOutdated($mount->getId(), $path);
+ $this->markParentAsOutdated($mount->getId(), $change->getPath());
});
}
@@ -147,8 +149,8 @@ class Notify extends Base {
$this->updateQuery->execute([$parent, $mountId]);
}
- private function logUpdate($type, $path, $renameTarget, OutputInterface $output) {
- switch ($type) {
+ private function logUpdate(IChange $change, OutputInterface $output) {
+ switch ($change->getType()) {
case INotifyStorage::NOTIFY_ADDED:
$text = 'added';
break;
@@ -165,9 +167,9 @@ class Notify extends Base {
return;
}
- $text .= ' ' . $path;
- if ($type === INotifyStorage::NOTIFY_RENAMED) {
- $text .= ' to ' . $renameTarget;
+ $text .= ' ' . $change->getPath();
+ if ($change instanceof IRenameChange) {
+ $text .= ' to ' . $change->getTargetPath();
}
$output->writeln($text);