mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-30 19:52:17 +01:00
Extracting closures into methods to solve php 5.3 issue #546
This commit is contained in:
parent
73c35f43aa
commit
17f679076e
@ -193,19 +193,6 @@ class ImportController extends Controller {
|
|||||||
$file = $view->file_get_contents('/imports/' . $filename);
|
$file = $view->file_get_contents('/imports/' . $filename);
|
||||||
\OC_FileProxy::$enabled = $proxyStatus;
|
\OC_FileProxy::$enabled = $proxyStatus;
|
||||||
|
|
||||||
$writeProgress = function($pct, $total) use ($progresskey) {
|
|
||||||
$this->cache->set($progresskey, $pct, 300);
|
|
||||||
$this->cache->set($progresskey.'_total', $total, 300);
|
|
||||||
};
|
|
||||||
|
|
||||||
$cleanup = function() use ($view, $filename, $progresskey, $response) {
|
|
||||||
if(!$view->unlink('/imports/' . $filename)) {
|
|
||||||
$response->debug('Unable to unlink /imports/' . $filename);
|
|
||||||
}
|
|
||||||
$this->cache->remove($progresskey);
|
|
||||||
$this->cache->remove($progresskey.'_total');
|
|
||||||
};
|
|
||||||
|
|
||||||
$importManager = new ImportManager();
|
$importManager = new ImportManager();
|
||||||
|
|
||||||
$formatList = $importManager->getTypes();
|
$formatList = $importManager->getTypes();
|
||||||
@ -271,7 +258,7 @@ class ImportController extends Controller {
|
|||||||
$failed++;
|
$failed++;
|
||||||
}
|
}
|
||||||
$processed++;
|
$processed++;
|
||||||
$writeProgress($processed, $total);
|
$this->writeProcess($processed, $total, $progresskey);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$imported = 0;
|
$imported = 0;
|
||||||
@ -279,7 +266,8 @@ class ImportController extends Controller {
|
|||||||
$processed = 0;
|
$processed = 0;
|
||||||
$total = 0;
|
$total = 0;
|
||||||
}
|
}
|
||||||
$cleanup();
|
|
||||||
|
$this->cleanup($view, $filename, $progresskey, $response);
|
||||||
//done the import
|
//done the import
|
||||||
sleep(3); // Give client side a chance to read the progress.
|
sleep(3); // Give client side a chance to read the progress.
|
||||||
$response->setParams(
|
$response->setParams(
|
||||||
@ -296,6 +284,30 @@ class ImportController extends Controller {
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $pct
|
||||||
|
* @param $total
|
||||||
|
* @param $progresskey
|
||||||
|
*/
|
||||||
|
protected function writeProcess($pct, $total, $progresskey) {
|
||||||
|
$this->cache->set($progresskey, $pct, 300);
|
||||||
|
$this->cache->set($progresskey . '_total', $total, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $view
|
||||||
|
* @param $filename
|
||||||
|
* @param $progresskey
|
||||||
|
* @param $response
|
||||||
|
*/
|
||||||
|
protected function cleanup($view, $filename, $progresskey, $response) {
|
||||||
|
if (!$view->unlink('/imports/' . $filename)) {
|
||||||
|
$response->debug('Unable to unlink /imports/' . $filename);
|
||||||
|
}
|
||||||
|
$this->cache->remove($progresskey);
|
||||||
|
$this->cache->remove($progresskey . '_total');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user