fixing indent
This commit is contained in:
parent
e560cba76b
commit
5ff29b4348
|
@ -29,12 +29,12 @@ $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
|
||||||
|
|
||||||
if($success) {
|
if($success) {
|
||||||
OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files,
|
OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files,
|
||||||
'uploadMaxFilesize'=>$maxUploadFilesize,
|
'uploadMaxFilesize'=>$maxUploadFilesize,
|
||||||
'maxHumanFilesize'=>$maxHumanFilesize
|
'maxHumanFilesize'=>$maxHumanFilesize
|
||||||
)));
|
)));
|
||||||
} else {
|
} else {
|
||||||
OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError,
|
OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError,
|
||||||
'uploadMaxFilesize'=>$maxUploadFilesize,
|
'uploadMaxFilesize'=>$maxUploadFilesize,
|
||||||
'maxHumanFilesize'=>$maxHumanFilesize
|
'maxHumanFilesize'=>$maxHumanFilesize
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,9 @@ $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
|
||||||
|
|
||||||
if (!isset($_FILES['files'])) {
|
if (!isset($_FILES['files'])) {
|
||||||
OCP\JSON::error(array('data' => array( 'message' => $l->t( 'No file was uploaded. Unknown error' ),
|
OCP\JSON::error(array('data' => array( 'message' => $l->t( 'No file was uploaded. Unknown error' ),
|
||||||
'uploadMaxFilesize'=>$maxUploadFilesize,
|
'uploadMaxFilesize'=>$maxUploadFilesize,
|
||||||
'maxHumanFilesize'=>$maxHumanFilesize
|
'maxHumanFilesize'=>$maxHumanFilesize
|
||||||
)));
|
)));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ foreach ($_FILES['files']['error'] as $error) {
|
||||||
UPLOAD_ERR_CANT_WRITE=>$l->t('Failed to write to disk'),
|
UPLOAD_ERR_CANT_WRITE=>$l->t('Failed to write to disk'),
|
||||||
);
|
);
|
||||||
OCP\JSON::error(array('data' => array( 'message' => $errors[$error],
|
OCP\JSON::error(array('data' => array( 'message' => $errors[$error],
|
||||||
'uploadMaxFilesize'=>$maxUploadFilesize,
|
'uploadMaxFilesize'=>$maxUploadFilesize,
|
||||||
'maxHumanFilesize'=>$maxHumanFilesize
|
'maxHumanFilesize'=>$maxHumanFilesize
|
||||||
)));
|
)));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ foreach($files['size'] as $size) {
|
||||||
}
|
}
|
||||||
if($totalSize>OC_Filesystem::free_space($dir)) {
|
if($totalSize>OC_Filesystem::free_space($dir)) {
|
||||||
OCP\JSON::error(array('data' => array( 'message' => $l->t( 'Not enough space available' ),
|
OCP\JSON::error(array('data' => array( 'message' => $l->t( 'Not enough space available' ),
|
||||||
'uploadMaxFilesize'=>$maxUploadFilesize,
|
'uploadMaxFilesize'=>$maxUploadFilesize,
|
||||||
'maxHumanFilesize'=>$maxHumanFilesize)));
|
'maxHumanFilesize'=>$maxHumanFilesize)));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,19 +70,19 @@ if(strpos($dir, '..') === false) {
|
||||||
if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
|
if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
|
||||||
$meta = OC_FileCache::get($target);
|
$meta = OC_FileCache::get($target);
|
||||||
$id = OC_FileCache::getId($target);
|
$id = OC_FileCache::getId($target);
|
||||||
// updated max file size after upload
|
// updated max file size after upload
|
||||||
$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
|
$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
|
||||||
$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize);
|
$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize);
|
||||||
$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
|
$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
|
||||||
|
|
||||||
$result[]=array( 'status' => 'success',
|
$result[]=array( 'status' => 'success',
|
||||||
'mime'=>$meta['mimetype'],
|
'mime'=>$meta['mimetype'],
|
||||||
'size'=>$meta['size'],
|
'size'=>$meta['size'],
|
||||||
'id'=>$id,
|
'id'=>$id,
|
||||||
'name'=>basename($target),
|
'name'=>basename($target),
|
||||||
'uploadMaxFilesize'=>$maxUploadFilesize,
|
'uploadMaxFilesize'=>$maxUploadFilesize,
|
||||||
'maxHumanFilesize'=>$maxHumanFilesize
|
'maxHumanFilesize'=>$maxHumanFilesize
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OCP\JSON::encodedPrint($result);
|
OCP\JSON::encodedPrint($result);
|
||||||
|
@ -92,6 +92,6 @@ if(strpos($dir, '..') === false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
OCP\JSON::error(array('data' => array('message' => $error,
|
OCP\JSON::error(array('data' => array('message' => $error,
|
||||||
'uploadMaxFilesize'=>$maxUploadFilesize,
|
'uploadMaxFilesize'=>$maxUploadFilesize,
|
||||||
'maxHumanFilesize'=>$maxHumanFilesize
|
'maxHumanFilesize'=>$maxHumanFilesize
|
||||||
)));
|
)));
|
||||||
|
|
|
@ -26,23 +26,23 @@ Files={
|
||||||
});
|
});
|
||||||
procesSelection();
|
procesSelection();
|
||||||
},
|
},
|
||||||
updateMaxUploadFilesize:function(response) {
|
updateMaxUploadFilesize:function(response) {
|
||||||
if(response == undefined) {
|
if(response == undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) {
|
if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) {
|
||||||
$('#max_upload').val(response.data.uploadMaxFilesize);
|
$('#max_upload').val(response.data.uploadMaxFilesize);
|
||||||
$('#data-upload-form a').attr('original-title', response.data.maxHumanFilesize);
|
$('#data-upload-form a').attr('original-title', response.data.maxHumanFilesize);
|
||||||
}
|
}
|
||||||
if(response[0] == undefined) {
|
if(response[0] == undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(response[0].uploadMaxFilesize !== undefined) {
|
if(response[0].uploadMaxFilesize !== undefined) {
|
||||||
$('#max_upload').val(response[0].uploadMaxFilesize);
|
$('#max_upload').val(response[0].uploadMaxFilesize);
|
||||||
$('#data-upload-form a').attr('original-title', response[0].maxHumanFilesize);
|
$('#data-upload-form a').attr('original-title', response[0].maxHumanFilesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
isFileNameValid:function (name) {
|
isFileNameValid:function (name) {
|
||||||
if (name === '.') {
|
if (name === '.') {
|
||||||
$('#notification').text(t('files', '\'.\' is an invalid file name.'));
|
$('#notification').text(t('files', '\'.\' is an invalid file name.'));
|
||||||
|
@ -333,7 +333,7 @@ $(document).ready(function() {
|
||||||
$('#notification').text(t('files', response.data.message));
|
$('#notification').text(t('files', response.data.message));
|
||||||
$('#notification').fadeIn();
|
$('#notification').fadeIn();
|
||||||
}
|
}
|
||||||
Files.updateMaxUploadFilesize(response);
|
Files.updateMaxUploadFilesize(response);
|
||||||
var file=response[0];
|
var file=response[0];
|
||||||
// TODO: this doesn't work if the file name has been changed server side
|
// TODO: this doesn't work if the file name has been changed server side
|
||||||
delete uploadingFiles[dirName][file.name];
|
delete uploadingFiles[dirName][file.name];
|
||||||
|
@ -386,9 +386,9 @@ $(document).ready(function() {
|
||||||
.success(function(result, textStatus, jqXHR) {
|
.success(function(result, textStatus, jqXHR) {
|
||||||
var response;
|
var response;
|
||||||
response=jQuery.parseJSON(result);
|
response=jQuery.parseJSON(result);
|
||||||
Files.updateMaxUploadFilesize(response);
|
Files.updateMaxUploadFilesize(response);
|
||||||
|
|
||||||
if(response[0] != undefined && response[0].status == 'success') {
|
if(response[0] != undefined && response[0].status == 'success') {
|
||||||
var file=response[0];
|
var file=response[0];
|
||||||
delete uploadingFiles[file.name];
|
delete uploadingFiles[file.name];
|
||||||
$('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id);
|
$('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id);
|
||||||
|
@ -421,8 +421,8 @@ $(document).ready(function() {
|
||||||
data.submit().success(function(data, status) {
|
data.submit().success(function(data, status) {
|
||||||
// in safari data is a string
|
// in safari data is a string
|
||||||
response = jQuery.parseJSON(typeof data === 'string' ? data : data[0].body.innerText);
|
response = jQuery.parseJSON(typeof data === 'string' ? data : data[0].body.innerText);
|
||||||
Files.updateMaxUploadFilesize(response);
|
Files.updateMaxUploadFilesize(response);
|
||||||
if(response[0] != undefined && response[0].status == 'success') {
|
if(response[0] != undefined && response[0].status == 'success') {
|
||||||
var file=response[0];
|
var file=response[0];
|
||||||
delete uploadingFiles[file.name];
|
delete uploadingFiles[file.name];
|
||||||
$('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id);
|
$('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id);
|
||||||
|
@ -787,7 +787,7 @@ scanFiles.scanning=false;
|
||||||
|
|
||||||
function boolOperationFinished(data, callback) {
|
function boolOperationFinished(data, callback) {
|
||||||
result = jQuery.parseJSON(data.responseText);
|
result = jQuery.parseJSON(data.responseText);
|
||||||
Files.updateMaxUploadFilesize(result);
|
Files.updateMaxUploadFilesize(result);
|
||||||
if(result.status == 'success'){
|
if(result.status == 'success'){
|
||||||
callback.call();
|
callback.call();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -695,8 +695,8 @@ class OC_Helper {
|
||||||
$start = intval($start);
|
$start = intval($start);
|
||||||
$length = intval($length);
|
$length = intval($length);
|
||||||
$string = mb_substr($string, 0, $start, $encoding) .
|
$string = mb_substr($string, 0, $start, $encoding) .
|
||||||
$replacement .
|
$replacement .
|
||||||
mb_substr($string, $start+$length, mb_strlen($string, 'UTF-8')-$start, $encoding);
|
mb_substr($string, $start+$length, mb_strlen($string, 'UTF-8')-$start, $encoding);
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
@ -764,22 +764,22 @@ class OC_Helper {
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief calculates the maximum upload size respecting system settings, free space and user quota
|
* @brief calculates the maximum upload size respecting system settings, free space and user quota
|
||||||
*
|
*
|
||||||
* @param $dir the current folder where the user currently operates
|
* @param $dir the current folder where the user currently operates
|
||||||
* @return number of bytes representing
|
* @return number of bytes representing
|
||||||
*/
|
*/
|
||||||
public static function maxUploadFilesize($dir) {
|
public static function maxUploadFilesize($dir) {
|
||||||
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
|
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
|
||||||
$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
|
$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
|
||||||
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
|
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
|
||||||
|
|
||||||
$freeSpace = OC_Filesystem::free_space($dir);
|
$freeSpace = OC_Filesystem::free_space($dir);
|
||||||
$freeSpace = max($freeSpace, 0);
|
$freeSpace = max($freeSpace, 0);
|
||||||
|
|
||||||
return min($maxUploadFilesize, $freeSpace);
|
return min($maxUploadFilesize, $freeSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a function is available
|
* Checks if a function is available
|
||||||
|
|
|
@ -203,7 +203,7 @@ class Util {
|
||||||
$host_name = self::getServerHostName();
|
$host_name = self::getServerHostName();
|
||||||
// handle localhost installations
|
// handle localhost installations
|
||||||
if ($host_name === 'localhost') {
|
if ($host_name === 'localhost') {
|
||||||
$host_name = "example.com";
|
$host_name = "example.com";
|
||||||
}
|
}
|
||||||
return $user_part.'@'.$host_name;
|
return $user_part.'@'.$host_name;
|
||||||
}
|
}
|
||||||
|
@ -368,13 +368,13 @@ class Util {
|
||||||
return(\OC_Helper::recursiveArraySearch($haystack, $needle, $index));
|
return(\OC_Helper::recursiveArraySearch($haystack, $needle, $index));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief calculates the maximum upload size respecting system settings, free space and user quota
|
* @brief calculates the maximum upload size respecting system settings, free space and user quota
|
||||||
*
|
*
|
||||||
* @param $dir the current folder where the user currently operates
|
* @param $dir the current folder where the user currently operates
|
||||||
* @return number of bytes representing
|
* @return number of bytes representing
|
||||||
*/
|
*/
|
||||||
public static function maxUploadFilesize($dir) {
|
public static function maxUploadFilesize($dir) {
|
||||||
return \OC_Helper::maxUploadFilesize($dir);
|
return \OC_Helper::maxUploadFilesize($dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue