scan.php 827 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. set_time_limit(0);//scanning can take ages
  3. $force=isset($_GET['force']) and $_GET['force']=='true';
  4. $dir=isset($_GET['dir'])?$_GET['dir']:'';
  5. $checkOnly=isset($_GET['checkonly']) and $_GET['checkonly']=='true';
  6. if(!$checkOnly){
  7. $eventSource=new OC_EventSource();
  8. }
  9. session_write_close();
  10. //create the file cache if necesary
  11. if($force or !OC_FileCache::inCache('')){
  12. if(!$checkOnly){
  13. OCP\DB::beginTransaction();
  14. OC_FileCache::scan($dir,$eventSource);
  15. OC_FileCache::clean();
  16. OCP\DB::commit();
  17. $eventSource->send('success',true);
  18. }else{
  19. OCP\JSON::success(array('data'=>array('done'=>true)));
  20. exit;
  21. }
  22. }else{
  23. if($checkOnly){
  24. OCP\JSON::success(array('data'=>array('done'=>false)));
  25. exit;
  26. }
  27. if(isset($eventSource)){
  28. $eventSource->send('success',false);
  29. }else{
  30. exit;
  31. }
  32. }
  33. $eventSource->close();