]> source.dussan.org Git - nextcloud-server.git/commitdiff
Ignore favorites that are not available when creating the favorites list
authorJoas Schilling <nickvergessen@gmx.de>
Mon, 19 Jan 2015 16:05:43 +0000 (17:05 +0100)
committerJoas Schilling <nickvergessen@gmx.de>
Fri, 23 Jan 2015 09:11:14 +0000 (10:11 +0100)
Also correctly return the exception for all cases when adding/removing favos

apps/files/controller/apicontroller.php
apps/files/service/tagservice.php

index 902731a0492c9058592104378130e4e5def177b5..a8bea27e4bbfae906729e2fde68b5a0ea8808552 100644 (file)
@@ -67,6 +67,7 @@ class ApiController extends Controller {
         *
         * @param string $path path
         * @param array  $tags array of tags
+        * @return DataResponse
         */
        public function updateFileTags($path, $tags = null) {
                $result = array();
@@ -76,6 +77,10 @@ class ApiController extends Controller {
                                $this->tagService->updateFileTags($path, $tags);
                        } catch (\OCP\Files\NotFoundException $e) {
                                return new DataResponse($e->getMessage(), Http::STATUS_NOT_FOUND);
+                       } catch (\OCP\Files\StorageNotAvailableException $e) {
+                               return new DataResponse($e->getMessage(), Http::STATUS_SERVICE_UNAVAILABLE);
+                       } catch (\Exception $e) {
+                               return new DataResponse($e->getMessage(), Http::STATUS_NOT_FOUND);
                        }
                        $result['tags'] = $tags;
                }
@@ -89,6 +94,7 @@ class ApiController extends Controller {
         * @CORS
         *
         * @param array $tagName tag name to filter by
+        * @return DataResponse
         */
        public function getFilesByTag($tagName) {
                $files = array();
index 86885e38ddd481e39f1b2735103e1660d2a4ad8a..fe26838552a19f1d16f793c9969601ec6aad10ef 100644 (file)
@@ -8,6 +8,8 @@
 
 namespace OCA\Files\Service;
 
+use OC\Files\FileInfo;
+
 /**
  * Service class to manage tags on files.
  */
@@ -84,11 +86,19 @@ class TagService {
                $nodes = $this->homeFolder->searchByTag(
                        $tagName, $this->userSession->getUser()->getUId()
                );
-               foreach ($nodes as &$node) {
-                       $node = $node->getFileInfo();
+               $fileInfos = [];
+               foreach ($nodes as $node) {
+                       try {
+                               /** @var \OC\Files\Node\Node $node */
+                               $fileInfos[] = $node->getFileInfo();
+                       } catch (\Exception $e) {
+                               // FIXME Should notify the user, when this happens
+                               // Can not get FileInfo, maybe the connection to the external
+                               // storage is interrupted.
+                       }
                }
 
-               return $nodes;
+               return $fileInfos;
        }
 }