]> source.dussan.org Git - nextcloud-server.git/commitdiff
merge master into filesytem
authorRobin Appelman <icewind@owncloud.com>
Sun, 20 Jan 2013 02:11:04 +0000 (03:11 +0100)
committerRobin Appelman <icewind@owncloud.com>
Sun, 20 Jan 2013 02:11:04 +0000 (03:11 +0100)
1  2 
apps/files/ajax/delete.php
apps/files/ajax/upload.php
apps/files/index.php
apps/files/js/files.js
lib/app.php
lib/base.php
lib/helper.php

Simple merge
index eea66d6b269a9b3bd32d2ffc65d777a0c154234c,933980196086f94321acc265457dce5d9232ccd3..b4a2035301e2a21e5dd2e2f430dea5f2b1c58200
@@@ -41,8 -53,10 +53,10 @@@ $totalSize=0
  foreach($files['size'] as $size) {
        $totalSize+=$size;
  }
 -if($totalSize>OC_Filesystem::free_space($dir)) {
 +if($totalSize>\OC\Files\Filesystem::free_space($dir)) {
-       OCP\JSON::error(array('data' => array( 'message' => 'Not enough space available' )));
+       OCP\JSON::error(array('data' => array( 'message' => $l->t( 'Not enough space available' ),
+               'uploadMaxFilesize'=>$maxUploadFilesize,
+               'maxHumanFilesize'=>$maxHumanFilesize)));
        exit();
  }
  
@@@ -52,14 -66,23 +66,22 @@@ if(strpos($dir, '..') === false) 
        for($i=0;$i<$fileCount;$i++) {
                $target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
                // $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
 -              $target = OC_Filesystem::normalizePath($target);
 -              if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
 -                      $meta = OC_FileCache::get($target);
 -                      $id = OC_FileCache::getId($target);
 +              $target = \OC\Files\Filesystem::normalizePath($target);
 +              if(is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
 +                      $meta = \OC\Files\Filesystem::getFileInfo($target);
+                       // updated max file size after upload
+                       $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
+                       $maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize);
+                       $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
                        $result[]=array( 'status' => 'success',
                                'mime'=>$meta['mimetype'],
                                'size'=>$meta['size'],
 -                              'id'=>$id,
 +                              'id'=>$meta['fileid'],
-                               'name'=>basename($target));
+                               'name'=>basename($target),
+                               'uploadMaxFilesize'=>$maxUploadFilesize,
+                               'maxHumanFilesize'=>$maxHumanFilesize
+                       );
                }
        }
        OCP\JSON::encodedPrint($result);
index 854218eee552c5e60f27fc8572c5ca6ef2ec60fd,1c4b7fbd497aba5119b3878b4f6d51d35eddaa03..c10ae76e9eaf46e2b854f58ca7d879ea695f6ee1
@@@ -28,8 -28,11 +28,9 @@@ OCP\User::checkLoggedIn()
  OCP\Util::addStyle('files', 'files');
  OCP\Util::addscript('files', 'jquery.iframe-transport');
  OCP\Util::addscript('files', 'jquery.fileupload');
 -OCP\Util::addscript('files', 'files');
+ OCP\Util::addscript('files', 'jquery-visibility');
  OCP\Util::addscript('files', 'filelist');
  OCP\Util::addscript('files', 'fileactions');
 -OCP\Util::addscript('files', 'keyboardshortcuts');
  
  OCP\App::setActiveNavigationEntry('files_index');
  // Load the files
@@@ -97,21 -80,16 +98,16 @@@ $breadcrumbNav = new OCP\Template('file
  $breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
  $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false);
  
- $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
- $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
- $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
- $freeSpace = max($freeSpace, 0);
- $maxUploadFilesize = min($maxUploadFilesize, $freeSpace);
+ $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
  
  $permissions = OCP\PERMISSION_READ;
 -if (OC_Filesystem::isUpdatable($dir . '/')) {
 +if (\OC\Files\Filesystem::isUpdatable($dir . '/')) {
        $permissions |= OCP\PERMISSION_UPDATE;
  }
 -if (OC_Filesystem::isDeletable($dir . '/')) {
 +if (\OC\Files\Filesystem::isDeletable($dir . '/')) {
        $permissions |= OCP\PERMISSION_DELETE;
  }
 -if (OC_Filesystem::isSharable($dir . '/')) {
 +if (\OC\Files\Filesystem::isSharable($dir . '/')) {
        $permissions |= OCP\PERMISSION_SHARE;
  }
  
index f560e9084568234095c7566a1a94240136af7b27,c1abe205151f285aed8d39f751048c527025fe30..1c3926e05d959bef7de92992973407ed1e9f0a6d
@@@ -708,25 -733,55 +729,51 @@@ $(document).ready(function() 
        });
  
        resizeBreadcrumbs(true);
+       // file space size sync
+       function update_storage_statistics() {
+               $.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) {
+                       Files.updateMaxUploadFilesize(response);
+               });
+       }
+       // start on load - we ask the server every 5 minutes
+       var update_storage_statistics_interval = 5*60*1000;
+       var update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval);
+       // Use jquery-visibility to de-/re-activate file stats sync
+       if ($.support.pageVisibility) {
+               $(document).on({
+                       'show.visibility': function() {
+                               if (!update_storage_statistics_interval_id) {
+                                       update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval);
+                               }
+                       },
+                       'hide.visibility': function() {
+                               clearInterval(update_storage_statistics_interval_id);
+                               update_storage_statistics_interval_id = 0;
+                       }
+               });
+       }
  });
  
 -function scanFiles(force,dir){
 +function scanFiles(force, dir){
        if(!dir){
 -              dir='';
 +              dir = '';
        }
 -      force=!!force; //cast to bool
 -      scanFiles.scanning=true;
 -      $('#scanning-message').show();
 -      $('#fileList').remove();
 -      var scannerEventSource=new OC.EventSource(OC.filePath('files','ajax','scan.php'),{force:force,dir:dir});
 -      scanFiles.cancel=scannerEventSource.close.bind(scannerEventSource);
 -      scannerEventSource.listen('scanning',function(data){
 -              $('#scan-count').text(t('files', '{count} files scanned', {count: data.count}));
 -              $('#scan-current').text(data.file+'/');
 +      force = !!force; //cast to bool
 +      scanFiles.scanning = true;
 +      var scannerEventSource = new OC.EventSource(OC.filePath('files','ajax','scan.php'),{force:force,dir:dir});
 +      scanFiles.cancel = scannerEventSource.close.bind(scannerEventSource);
 +      scannerEventSource.listen('count',function(count){
 +              console.log(count + 'files scanned')
 +      });
 +      scannerEventSource.listen('folder',function(path){
 +              console.log('now scanning ' + path)
        });
 -      scannerEventSource.listen('success',function(success){
 +      scannerEventSource.listen('done',function(count){
                scanFiles.scanning=false;
 -              if(success){
 -                      window.location.reload();
 -              }else{
 -                      alert(t('files', 'error while scanning'));
 -              }
 +              console.log('done after ' + count + 'files');
        });
  }
  scanFiles.scanning=false;
diff --cc lib/app.php
index 68e1bc6a6ca712a5c5773a7b90c1fc9fd44de21e,662af56d2581355b24020506d683a87cc962051d..0f1fa2c5ec2ad0ca3c2e144f39f22a679ad133b4
@@@ -746,9 -746,9 +746,9 @@@ class OC_App
                                if(!$view->file_exists($appid)) {
                                        $view->mkdir($appid);
                                }
 -                              return new OC_FilesystemView('/'.OC_User::getUser().'/'.$appid);
 +                              return new \OC\Files\View('/'.OC_User::getUser().'/'.$appid);
                        }else{
-                               OC_Log::write('core', 'Can\'t get app storage, app, user not logged in', OC_Log::ERROR);
+                               OC_Log::write('core', 'Can\'t get app storage, app '.$appid.', user not logged in', OC_Log::ERROR);
                                return false;
                        }
                }else{
diff --cc lib/base.php
Simple merge
diff --cc lib/helper.php
Simple merge