22 private $fileInfoManager;
27 private $fileInfoFactory;
34 private $fileSubdirectoryPath =
'analytics/';
41 private $encodedFileName =
'data.tgz';
55 FileInfoFactory $fileInfoFactory,
59 $this->fileInfoFactory = $fileInfoFactory;
73 $fileRelativePath = $this->getFileRelativePath();
74 $directory->writeFile($fileRelativePath, $encodedContext->
getContent());
76 $fileInfo = $this->fileInfoManager->load();
77 $this->registerFile($encodedContext, $fileRelativePath);
78 $this->removeOldFile(
$fileInfo, $directory);
88 private function getFileRelativePath()
90 return $this->fileSubdirectoryPath . hash(
'sha256',
time())
91 .
'/' . $this->encodedFileName;
101 private function registerFile(EncodedContext $encodedContext, $fileRelativePath)
103 $newFileInfo = $this->fileInfoFactory->create(
105 'path' => $fileRelativePath,
106 'initializationVector' => $encodedContext->getInitializationVector(),
109 $this->fileInfoManager->save($newFileInfo);
121 private function removeOldFile(FileInfo
$fileInfo, WriteInterface $directory)
127 $directory->delete(
$fileInfo->getPath());
__construct(FileInfoManager $fileInfoManager, FileInfoFactory $fileInfoFactory, Filesystem $filesystem)
recordNewFile(EncodedContext $encodedContext)