summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/ajax
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-05-19 16:39:57 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-06-14 10:14:07 +0200
commit87b0021e5606888642b5798ba39b0525bf3f3e14 (patch)
tree2ccd1e719b7f83e6f70b015c370e41f5b0fd8ba4 /apps/files_sharing/ajax
parent30f5b2bd7cdb9dde211dd0d897f798190c8d3947 (diff)
downloadnextcloud-server-87b0021e5606888642b5798ba39b0525bf3f3e14.tar.gz
nextcloud-server-87b0021e5606888642b5798ba39b0525bf3f3e14.zip
Scan the entire remote share at once by requesting the full file tree from the remote server
Diffstat (limited to 'apps/files_sharing/ajax')
-rw-r--r--apps/files_sharing/ajax/external.php9
-rw-r--r--apps/files_sharing/ajax/shareinfo.php62
2 files changed, 70 insertions, 1 deletions
diff --git a/apps/files_sharing/ajax/external.php b/apps/files_sharing/ajax/external.php
index e7bf903f705..c25b34ab552 100644
--- a/apps/files_sharing/ajax/external.php
+++ b/apps/files_sharing/ajax/external.php
@@ -23,6 +23,13 @@ $externalManager = new \OCA\Files_Sharing\External\Manager(
);
$mount = $externalManager->addShare($remote, $token, $password, $name, $owner);
-$result = $mount->getStorage()->file_exists('');
+/**
+ * @var \OCA\Files_Sharing\External\Storage $storage
+ */
+$storage = $mount->getStorage();
+$result = $storage->file_exists('');
+if($result){
+ $storage->getScanner()->scanAll();
+}
echo json_encode($result);
diff --git a/apps/files_sharing/ajax/shareinfo.php b/apps/files_sharing/ajax/shareinfo.php
new file mode 100644
index 00000000000..4aefdbe7b15
--- /dev/null
+++ b/apps/files_sharing/ajax/shareinfo.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+if (!\OC_App::isEnabled('files_sharing')) {
+ exit;
+}
+
+if (!isset($_GET['t'])) {
+ \OC_Response::setStatus(400); //400 Bad Request
+ exit;
+}
+
+$token = $_GET['t'];
+
+$password = null;
+if (isset($_POST['password'])) {
+ $password = $_POST['password'];
+}
+
+$relativePath = null;
+if (isset($_GET['dir'])) {
+ $relativePath = $_GET['dir'];
+}
+
+$data = \OCA\Files_Sharing\Helper::setupFromToken($token, $relativePath, $password);
+
+$linkItem = $data['linkItem'];
+// Load the files
+$path = $data['realPath'];
+
+$rootInfo = \OC\Files\Filesystem::getFileInfo($path);
+$rootView = new \OC\Files\View('');
+
+/**
+ * @param \OCP\Files\FileInfo $dir
+ * @param \OC\Files\View $view
+ * @return array
+ */
+function getChildInfo($dir, $view) {
+ $children = $view->getDirectoryContent($dir->getPath());
+ $result = array();
+ foreach ($children as $child) {
+ $formated = \OCA\Files\Helper::formatFileInfo($child);
+ if ($child->getType() === 'dir') {
+ $formated['children'] = getChildInfo($child, $view);
+ }
+ $result[] = $formated;
+ }
+ return $result;
+}
+
+$result = \OCA\Files\Helper::formatFileInfo($rootInfo);
+if ($rootInfo->getType() === 'dir') {
+ $result['children'] = getChildInfo($rootInfo, $rootView);
+}
+
+OCP\JSON::success(array('data' => $result));