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();
}
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);
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
$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;
}
});
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;
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{