Skip to content

Commit

Permalink
Improvements on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vitormattos committed May 5, 2022
1 parent 12b8459 commit e3caf34
Show file tree
Hide file tree
Showing 5 changed files with 416 additions and 24 deletions.
29 changes: 9 additions & 20 deletions lib/Migration/Version2040Date20211027183759.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@

use Closure;
use Doctrine\DBAL\Types\Types;
use OC\SystemConfig;
use OCA\Libresign\AppInfo\Application;
use OCA\Libresign\Command\Install;
use OCA\Libresign\Service\PdfParserService;
use OCP\DB\ISchemaWrapper;
use OCP\Files\File;
use OCP\Files\IRootFolder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
Expand All @@ -22,28 +19,20 @@
class Version2040Date20211027183759 extends SimpleMigrationStep {
/** @var IRootFolder*/
private $root;
/** @var IDBConnection */
private $connection;
/** @var Install */
private $install;
/** @var IConfig */
private $config;
/** @var SystemConfig */
private $systemConfig;
/** @var PdfParserService */
private $PdfParserService;
/** @var array */
private $rows;
public function __construct(IRootFolder $root,
IDBConnection $connection,
IRootFolder $rootfolder,
Install $install,
IConfig $config,
SystemConfig $systemConfig) {
public function __construct(IDBConnection $connection,
IRootFolder $root,
PdfParserService $PdfParserService) {
$this->connection = $connection;
$this->install = $install;
$this->config = $config;
$this->systemConfig = $systemConfig;
$this->rootFolder = $rootfolder;
$this->root = $root;
$this->PdfParserService = $PdfParserService;
}

public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
Expand Down Expand Up @@ -81,15 +70,15 @@ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array
/** @var File[] */
$file = $userFolder->getById($row['node_id']);
if (count($file) >= 1) {
$data = $this->getMetadataFromCli($cli, $file[0]->getPath());
$data = $this->PdfParserService->getMetadata($file[0]->getPath());
$json = json_encode($data);
$query = $this->connection->getQueryBuilder();
$query
->update('libresign_file')
->set('metadata', $query->createNamedParameter($json))
->where($query->expr()->eq('id', $query->createNamedParameter($row['id'])));

$query->execute();
$query->executeStatement();
}
}
}
Expand Down
Loading

0 comments on commit e3caf34

Please sign in to comment.