Merge pull request #16718 from owncloud/files-catchajaxexceptions
Catch exceptions in files ajax calls
This commit is contained in:
commit
ccbb1cce3c
|
@ -54,10 +54,15 @@ $success = true;
|
||||||
|
|
||||||
//Now delete
|
//Now delete
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if (\OC\Files\Filesystem::file_exists($dir . '/' . $file) &&
|
try {
|
||||||
!(\OC\Files\Filesystem::isDeletable($dir . '/' . $file) &&
|
if (\OC\Files\Filesystem::file_exists($dir . '/' . $file) &&
|
||||||
\OC\Files\Filesystem::unlink($dir . '/' . $file))
|
!(\OC\Files\Filesystem::isDeletable($dir . '/' . $file) &&
|
||||||
) {
|
\OC\Files\Filesystem::unlink($dir . '/' . $file))
|
||||||
|
) {
|
||||||
|
$filesWithError .= $file . "\n";
|
||||||
|
$success = false;
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
$filesWithError .= $file . "\n";
|
$filesWithError .= $file . "\n";
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,10 +78,21 @@ $templateManager = OC_Helper::getFileTemplateManager();
|
||||||
$mimeType = OC_Helper::getMimetypeDetector()->detectPath($target);
|
$mimeType = OC_Helper::getMimetypeDetector()->detectPath($target);
|
||||||
$content = $templateManager->getTemplate($mimeType);
|
$content = $templateManager->getTemplate($mimeType);
|
||||||
|
|
||||||
if($content) {
|
try {
|
||||||
$success = \OC\Files\Filesystem::file_put_contents($target, $content);
|
if($content) {
|
||||||
} else {
|
$success = \OC\Files\Filesystem::file_put_contents($target, $content);
|
||||||
$success = \OC\Files\Filesystem::touch($target);
|
} else {
|
||||||
|
$success = \OC\Files\Filesystem::touch($target);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$result = [
|
||||||
|
'success' => false,
|
||||||
|
'data' => [
|
||||||
|
'message' => $e->getMessage()
|
||||||
|
]
|
||||||
|
];
|
||||||
|
OCP\JSON::error($result);
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($success) {
|
if($success) {
|
||||||
|
|
|
@ -74,15 +74,26 @@ if (\OC\Files\Filesystem::file_exists($target)) {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(\OC\Files\Filesystem::mkdir($target)) {
|
try {
|
||||||
if ( $dir !== '/') {
|
if(\OC\Files\Filesystem::mkdir($target)) {
|
||||||
$path = $dir.'/'.$folderName;
|
if ( $dir !== '/') {
|
||||||
} else {
|
$path = $dir.'/'.$folderName;
|
||||||
$path = '/'.$folderName;
|
} else {
|
||||||
|
$path = '/'.$folderName;
|
||||||
|
}
|
||||||
|
$meta = \OC\Files\Filesystem::getFileInfo($path);
|
||||||
|
$meta['type'] = 'dir'; // missing ?!
|
||||||
|
OCP\JSON::success(array('data' => \OCA\Files\Helper::formatFileInfo($meta)));
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
$meta = \OC\Files\Filesystem::getFileInfo($path);
|
} catch (\Exception $e) {
|
||||||
$meta['type'] = 'dir'; // missing ?!
|
$result = [
|
||||||
OCP\JSON::success(array('data' => \OCA\Files\Helper::formatFileInfo($meta)));
|
'success' => false,
|
||||||
|
'data' => [
|
||||||
|
'message' => $e->getMessage()
|
||||||
|
]
|
||||||
|
];
|
||||||
|
OCP\JSON::error($result);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,15 +29,26 @@ OCP\JSON::checkLoggedIn();
|
||||||
OCP\JSON::callCheck();
|
OCP\JSON::callCheck();
|
||||||
\OC::$server->getSession()->close();
|
\OC::$server->getSession()->close();
|
||||||
|
|
||||||
|
$l10n = \OC::$server->getL10N('files');
|
||||||
|
|
||||||
$files = new \OCA\Files\App(
|
$files = new \OCA\Files\App(
|
||||||
\OC\Files\Filesystem::getView(),
|
\OC\Files\Filesystem::getView(),
|
||||||
\OC::$server->getL10N('files')
|
\OC::$server->getL10N('files')
|
||||||
);
|
);
|
||||||
$result = $files->rename(
|
try {
|
||||||
isset($_GET['dir']) ? (string)$_GET['dir'] : '',
|
$result = $files->rename(
|
||||||
isset($_GET['file']) ? (string)$_GET['file'] : '',
|
isset($_GET['dir']) ? (string)$_GET['dir'] : '',
|
||||||
isset($_GET['newname']) ? (string)$_GET['newname'] : ''
|
isset($_GET['file']) ? (string)$_GET['file'] : '',
|
||||||
);
|
isset($_GET['newname']) ? (string)$_GET['newname'] : ''
|
||||||
|
);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$result = [
|
||||||
|
'success' => false,
|
||||||
|
'data' => [
|
||||||
|
'message' => $e->getMessage()
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
if($result['success'] === true){
|
if($result['success'] === true){
|
||||||
OCP\JSON::success(['data' => $result['data']]);
|
OCP\JSON::success(['data' => $result['data']]);
|
||||||
|
|
Loading…
Reference in New Issue