aboutsummaryrefslogtreecommitdiffstats
path: root/files/ajax/scan.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-02-08 15:50:58 +0100
committerRobin Appelman <icewind@owncloud.com>2012-02-08 15:50:58 +0100
commit5f7727629ad86dfb91c0f27c8f59eb97c100a95d (patch)
tree3806b5ffc2ccf5c432d4a4c0f951837971a4b100 /files/ajax/scan.php
parentcdf1cf82baef9764b3211017e7c3e63fb10676d3 (diff)
parente50dfbc2284e170b37735880d0a8694b89234400 (diff)
downloadnextcloud-server-5f7727629ad86dfb91c0f27c8f59eb97c100a95d.tar.gz
nextcloud-server-5f7727629ad86dfb91c0f27c8f59eb97c100a95d.zip
Merge branch 'filesystem'
Diffstat (limited to 'files/ajax/scan.php')
-rw-r--r--files/ajax/scan.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/files/ajax/scan.php b/files/ajax/scan.php
new file mode 100644
index 00000000000..565275911b4
--- /dev/null
+++ b/files/ajax/scan.php
@@ -0,0 +1,37 @@
+<?php
+
+require_once '../../lib/base.php';
+
+set_time_limit(0);//scanning can take ages
+
+$force=isset($_GET['force']) and $_GET['force']=='true';
+$checkOnly=isset($_GET['checkonly']) and $_GET['checkonly']=='true';
+
+if(!$checkOnly){
+ $eventSource=new OC_EventSource();
+}
+
+
+//create the file cache if necesary
+if($force or !OC_FileCache::inCache('')){
+ if(!$checkOnly){
+ OC_DB::beginTransaction();
+ OC_FileCache::scan('',$eventSource);
+ OC_DB::commit();
+ $eventSource->send('success',true);
+ }else{
+ OC_JSON::success(array('data'=>array('done'=>true)));
+ exit;
+ }
+}else{
+ if($checkOnly){
+ OC_JSON::success(array('data'=>array('done'=>false)));
+ exit;
+ }
+ if(isset($eventSource)){
+ $eventSource->send('success',false);
+ }else{
+ exit;
+ }
+}
+$eventSource->close(); \ No newline at end of file