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\Output\OutputInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
|
|
@ -32,15 +33,18 @@ class LoadWarrantySerialCommand extends Command
|
|||
protected $project_dir;
|
||||
protected $callback_url;
|
||||
protected $log_data;
|
||||
protected $filesystem;
|
||||
|
||||
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->upload_logger = $upload_logger;
|
||||
$this->load_logger = $load_logger;
|
||||
$this->project_dir = $kernel->getProjectDir();
|
||||
$this->callback_url = $callback_url;
|
||||
$this->filesystem = $filesystem;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
|
@ -81,7 +85,11 @@ class LoadWarrantySerialCommand extends Command
|
|||
|
||||
$output_info[] = $this->processWarrantySerialFile($filename, $user_id, $file_id, $orig_filename);
|
||||
|
||||
// remove entry from queue table
|
||||
$this->updateWarrantySerialQueue($id);
|
||||
|
||||
// delete the uploaded csv file and directory
|
||||
$this->deleteDirectoryAndFile($file_id);
|
||||
}
|
||||
|
||||
if (count($output_info) > 0)
|
||||
|
|
@ -409,6 +417,13 @@ class LoadWarrantySerialCommand extends Command
|
|||
$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)
|
||||
{
|
||||
$info = [
|
||||
|
|
|
|||
Loading…
Reference in a new issue