Delete csv file and directory after processing file. #708
This commit is contained in:
parent
6794db5f6a
commit
b4a6e233f1
1 changed files with 16 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\HttpKernel\KernelInterface;
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
|
@ -32,15 +33,18 @@ class LoadWarrantySerialCommand extends Command
|
||||||
protected $project_dir;
|
protected $project_dir;
|
||||||
protected $callback_url;
|
protected $callback_url;
|
||||||
protected $log_data;
|
protected $log_data;
|
||||||
|
protected $filesystem;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em, WarrantySerialUploadLogger $upload_logger,
|
public function __construct(EntityManagerInterface $em, WarrantySerialUploadLogger $upload_logger,
|
||||||
WarrantySerialLoadLogger $load_logger, KernelInterface $kernel, $callback_url)
|
WarrantySerialLoadLogger $load_logger, KernelInterface $kernel, $callback_url,
|
||||||
|
FileSystem $filesystem)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->upload_logger = $upload_logger;
|
$this->upload_logger = $upload_logger;
|
||||||
$this->load_logger = $load_logger;
|
$this->load_logger = $load_logger;
|
||||||
$this->project_dir = $kernel->getProjectDir();
|
$this->project_dir = $kernel->getProjectDir();
|
||||||
$this->callback_url = $callback_url;
|
$this->callback_url = $callback_url;
|
||||||
|
$this->filesystem = $filesystem;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
@ -81,7 +85,11 @@ class LoadWarrantySerialCommand extends Command
|
||||||
|
|
||||||
$output_info[] = $this->processWarrantySerialFile($filename, $user_id, $file_id, $orig_filename);
|
$output_info[] = $this->processWarrantySerialFile($filename, $user_id, $file_id, $orig_filename);
|
||||||
|
|
||||||
|
// remove entry from queue table
|
||||||
$this->updateWarrantySerialQueue($id);
|
$this->updateWarrantySerialQueue($id);
|
||||||
|
|
||||||
|
// delete the uploaded csv file and directory
|
||||||
|
$this->deleteDirectoryAndFile($file_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($output_info) > 0)
|
if (count($output_info) > 0)
|
||||||
|
|
@ -409,6 +417,13 @@ class LoadWarrantySerialCommand extends Command
|
||||||
$db->exec('UNLOCK TABLES;');
|
$db->exec('UNLOCK TABLES;');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function deleteDirectoryAndFile($filedir)
|
||||||
|
{
|
||||||
|
$csv_filedir = $this->project_dir . '/public/warranty_serial_uploads/' . $filedir;
|
||||||
|
|
||||||
|
$this->filesystem->remove($csv_filedir);
|
||||||
|
}
|
||||||
|
|
||||||
protected function setOutputInfo($filename, $file_id, $has_error, $error_message, $entries, $orig_filename)
|
protected function setOutputInfo($filename, $file_id, $has_error, $error_message, $entries, $orig_filename)
|
||||||
{
|
{
|
||||||
$info = [
|
$info = [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue