Improve temp file handling.

This commit is contained in:
Thomas Tanghus 2012-07-15 12:22:14 +02:00
parent 8b49e304e0
commit db034f05ca
1 changed files with 4 additions and 4 deletions

View File

@ -48,7 +48,7 @@ if(isset($_POST['method']) && $_POST['method'] == 'new'){
}else{ }else{
$id = $_POST['id']; $id = $_POST['id'];
if(!$id) { if(!$id) {
OCP\JSON::error(array('data' => array('message' => 'Error getting the ID of the address book.'))); OCP\JSON::error(array('data' => array('message' => 'Error getting the ID of the address book.', 'file'=>$_POST['file'])));
exit(); exit();
} }
OC_Contacts_App::getAddressbook($id); // is owner access check OC_Contacts_App::getAddressbook($id); // is owner access check
@ -79,7 +79,7 @@ writeProgress('70');
$imported = 0; $imported = 0;
$failed = 0; $failed = 0;
if(!count($parts) > 0) { if(!count($parts) > 0) {
OCP\JSON::error(array('data' => array('message' => 'No contacts to import in '.$_POST['file'].'. Please check if the file is corrupted.'))); OCP\JSON::error(array('data' => array('message' => 'No contacts to import in '.$_POST['file'].'. Please check if the file is corrupted.', 'file'=>$_POST['file'])));
exit(); exit();
} }
foreach($parts as $part){ foreach($parts as $part){
@ -102,8 +102,8 @@ writeProgress('100');
sleep(3); sleep(3);
OC_Cache::remove($progresskey); OC_Cache::remove($progresskey);
if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') { if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') {
if(!$view->unlink('/' . $_POST['file'])) { if(!$view->unlink('/imports/' . $_POST['file'])) {
OCP\Util::writeLog('contacts','Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], OCP\Util::ERROR); OCP\Util::writeLog('contacts','Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], OCP\Util::ERROR);
} }
} }
OCP\JSON::success(array('data' => array('imported'=>$imported, 'failed'=>$failed))); OCP\JSON::success(array('data' => array('imported'=>$imported, 'failed'=>$failed, 'file'=>$_POST['file'])));