Merge pull request #13889 from owncloud/catch-exception

Catch exception properly
remotes/origin/log-external-deletes
Morris Jobke 12 years ago
commit b2f6b8d62e
  1. 7
      apps/files/ajax/delete.php
  2. 19
      apps/files/lib/helper.php

@ -36,7 +36,12 @@ foreach ($files as $file) {
} }
// get array with updated storage stats (e.g. max file size) after upload // get array with updated storage stats (e.g. max file size) after upload
$storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir); try {
$storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
} catch(\OCP\Files\NotFoundException $e) {
OCP\JSON::error(['data' => ['message' => 'File not found']]);
return;
}
if ($success) { if ($success) {
OCP\JSON::success(array("data" => array_merge(array("dir" => $dir, "files" => $files), $storageStats))); OCP\JSON::success(array("data" => array_merge(array("dir" => $dir, "files" => $files), $storageStats)));

@ -13,21 +13,26 @@ use OCP\Files\FileInfo;
/** /**
* Helper class for manipulating file information * Helper class for manipulating file information
*/ */
class Helper class Helper {
{ /**
* @param string $dir
* @return array
* @throws \OCP\Files\NotFoundException
*/
public static function buildFileStorageStatistics($dir) { public static function buildFileStorageStatistics($dir) {
// information about storage capacities // information about storage capacities
$storageInfo = \OC_Helper::getStorageInfo($dir); $storageInfo = \OC_Helper::getStorageInfo($dir);
$l = new \OC_L10N('files'); $l = new \OC_L10N('files');
$maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']); $maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']);
$maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize); $maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
$maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize)); $maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize));
return array('uploadMaxFilesize' => $maxUploadFileSize, return [
'maxHumanFilesize' => $maxHumanFileSize, 'uploadMaxFilesize' => $maxUploadFileSize,
'freeSpace' => $storageInfo['free'], 'maxHumanFilesize' => $maxHumanFileSize,
'usedSpacePercent' => (int)$storageInfo['relative']); 'freeSpace' => $storageInfo['free'],
'usedSpacePercent' => (int)$storageInfo['relative']
];
} }
/** /**

Loading…
Cancel
Save