fix: import no longer writes fileadmin/products_import.info
The marker was display-only for the TYPO3 10 backend module, which is not ported. Locally fileadmin is hardlinked from the TYPO3 10 project, so writing it also changed that project's copy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
72465053cd
commit
18d84d65b0
2 files changed
-64
No files matched your search
@@ -37,7 +37,6 @@ final class ApiImportSource implements ProductImportSource, SingletonInterface,
|
||||
|
||||
private const STAGING_SUBDIR = 'ep_products_import';
|
||||
private const BASELINE_FILE = 'api-imported.info';
|
||||
private const IMPORT_MARKER = 'fileadmin/products_import.info';
|
||||
|
||||
/**
|
||||
* @var ApiClient|null
|
||||
@@ -93,8 +92,6 @@ final class ApiImportSource implements ProductImportSource, SingletonInterface,
|
||||
GeneralUtility::mkdir_deep(dirname($file));
|
||||
GeneralUtility::writeFile($file, $sourceGeneratedAt->format(\DateTimeInterface::ATOM), false);
|
||||
}
|
||||
|
||||
(new ImportTimestampService())->writeImportTimestamp(self::IMPORT_MARKER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpProducts\Service;
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
class ImportTimestampService
|
||||
{
|
||||
public function readImportTimestamp(string $importTimestampFile): ?\DateTime
|
||||
{
|
||||
$lastImportTimestampPath = GeneralUtility::getFileAbsFileName($importTimestampFile);
|
||||
if (!$lastImportTimestampPath || !file_exists($lastImportTimestampPath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$line = trim(file($lastImportTimestampPath)[0]);
|
||||
|
||||
if (empty($line)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return \DateTime::createFromFormat('d.m.Y H:i:s', $line);
|
||||
}
|
||||
|
||||
public function writeImportTimestamp(string $importTimestampFile): void
|
||||
{
|
||||
$lastImportTimestampPath = GeneralUtility::getFileAbsFileName($importTimestampFile);
|
||||
$now = new \DateTime('now');
|
||||
file_put_contents($lastImportTimestampPath, $now->format('d.m.Y H:i:s'));
|
||||
}
|
||||
|
||||
public function isImportRequired(string $uploadTimestampFile, string $importTimestampFile): bool
|
||||
{
|
||||
$updatedTimestampPath = GeneralUtility::getFileAbsFileName($uploadTimestampFile);
|
||||
|
||||
if (!$updatedTimestampPath || !file_exists($updatedTimestampPath)) {
|
||||
$this->writeImportTimestamp($importTimestampFile);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$line = trim(file($updatedTimestampPath)[0]);
|
||||
|
||||
if (empty($line)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$lastUploadAt = \DateTime::createFromFormat('d.m.Y H:i:s', $line);
|
||||
|
||||
$lastImportAt = $this->readImportTimestamp($importTimestampFile);
|
||||
|
||||
if (null === $lastImportAt || $lastUploadAt > $lastImportAt) {
|
||||
$this->writeImportTimestamp($importTimestampFile);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user