mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 04:23:19 +00:00
Cleanup temporary files
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
"neutron/silex-filesystem-provider": "~1.0",
|
||||
"neutron/sphinxsearch-api" : "~2.0.6",
|
||||
"neutron/recaptcha" : "~0.1.0",
|
||||
"neutron/temporary-filesystem" : "~2.0",
|
||||
"neutron/temporary-filesystem" : "~2.1",
|
||||
"php-xpdf/php-xpdf" : "~0.2.1",
|
||||
"phpexiftool/phpexiftool" : "~0.2, >=0.2.2",
|
||||
"silex/silex" : "~1.0.0",
|
||||
|
@@ -81,7 +81,7 @@ class RecordAdd extends Command
|
||||
|
||||
if ($input->getOption('in-place') !== '1') {
|
||||
$originalName = pathinfo($file, PATHINFO_BASENAME);
|
||||
$tempfile = tempnam(sys_get_temp_dir(), 'addrecord') . '.' . pathinfo($file, PATHINFO_EXTENSION);
|
||||
$tempfile = $this->container['temporary-filesystem']->createTemporaryFile('add_record', null, pathinfo($file, PATHINFO_EXTENSION));
|
||||
$this->container['monolog']->addInfo(sprintf('copy file from `%s` to temporary `%s`', $file, $tempfile));
|
||||
$this->container['filesystem']->copy($file, $tempfile, true);
|
||||
$file = $tempfile;
|
||||
@@ -97,6 +97,7 @@ class RecordAdd extends Command
|
||||
if ($input->getOption('force')) {
|
||||
switch ($input->getOption('force')) {
|
||||
default:
|
||||
$this->container['temporary-filesystem']->clean('add_record');
|
||||
throw new \InvalidArgumentException(sprintf('`%s` is not a valid force option', $input->getOption('force')));
|
||||
break;
|
||||
case 'record':
|
||||
@@ -130,7 +131,7 @@ class RecordAdd extends Command
|
||||
|
||||
if ($tempfile) {
|
||||
$this->container['monolog']->addInfo(sprintf('Remove temporary file `%s`', $tempfile));
|
||||
$this->container['filesystem']->remove($tempfile);
|
||||
$this->container['temporary-filesystem']->clean('add_record');
|
||||
}
|
||||
|
||||
return;
|
||||
|
@@ -231,6 +231,7 @@ class Configuration implements ConfigurationInterface
|
||||
}
|
||||
}
|
||||
|
||||
unlink($tmpFile);
|
||||
throw new RuntimeException(sprintf('Unable to write %s', $file));
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Alchemy\Phrasea\Core\Provider;
|
||||
|
||||
use Neutron\TemporaryFilesystem\TemporaryFilesystem;
|
||||
use Neutron\TemporaryFilesystem\Manager;
|
||||
use Silex\Application;
|
||||
use Silex\ServiceProviderInterface;
|
||||
|
||||
@@ -19,9 +20,12 @@ class TemporaryFilesystemServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Application $app)
|
||||
{
|
||||
$app['temporary-filesystem'] = $app->share(function (Application $app) {
|
||||
$app['temporary-filesystem.temporary-fs'] = $app->share(function (Application $app) {
|
||||
return new TemporaryFilesystem($app['filesystem']);
|
||||
});
|
||||
$app['temporary-filesystem'] = $app->share(function (Application $app) {
|
||||
return new Manager($app['temporary-filesystem.temporary-fs'], $app['filesystem']);
|
||||
});
|
||||
}
|
||||
|
||||
public function boot(Application $app)
|
||||
|
@@ -10,7 +10,7 @@ class TemporaryFilesystemServiceProvidertest extends ServiceProviderTestCase
|
||||
public function provideServiceDescription()
|
||||
{
|
||||
return array(
|
||||
array('Alchemy\Phrasea\Core\Provider\TemporaryFilesystemServiceProvider', 'temporary-filesystem', 'Neutron\TemporaryFilesystem\TemporaryFilesystem'),
|
||||
array('Alchemy\Phrasea\Core\Provider\TemporaryFilesystemServiceProvider', 'temporary-filesystem', 'Neutron\TemporaryFilesystem\TemporaryFilesystemInterface'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user