Update DropFile to handle object versioning

This commit is contained in:
2024-09-02 16:24:23 +02:00
parent b6edbb3eed
commit 3d49c959e0
42 changed files with 857 additions and 539 deletions

View File

@@ -23,6 +23,7 @@ use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
use Random\RandomException;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Represent a document stored in an object store.
@@ -37,7 +38,6 @@ use Symfony\Component\Serializer\Annotation as Serializer;
*/
#[ORM\Entity]
#[ORM\Table('stored_object', schema: 'chill_doc')]
#[AsyncFileExists(message: 'The file is not stored properly')]
class StoredObject implements Document, TrackCreationInterface
{
use TrackCreationTrait;
@@ -91,7 +91,7 @@ class StoredObject implements Document, TrackCreationInterface
/**
* @var Collection<int, StoredObjectVersion>
*/
#[ORM\OneToMany(targetEntity: StoredObjectVersion::class, cascade: ['persist'], mappedBy: 'storedObject', orphanRemoval: true)]
#[ORM\OneToMany(mappedBy: 'storedObject', targetEntity: StoredObjectVersion::class, cascade: ['persist'], orphanRemoval: true)]
private Collection $versions;
/**
@@ -127,6 +127,8 @@ class StoredObject implements Document, TrackCreationInterface
return \DateTime::createFromImmutable($this->createdAt);
}
#[AsyncFileExists(message: 'The file is not stored properly')]
#[Assert\NotNull(message: 'The store object version must be present')]
public function getCurrentVersion(): ?StoredObjectVersion
{
$maxVersion = null;
@@ -350,20 +352,7 @@ class StoredObject implements Document, TrackCreationInterface
/**
* @deprecated
*/
public function saveHistory(): void
{
if ('' === $this->getFilename()) {
return;
}
$this->datas['history'][] = [
'filename' => $this->getFilename(),
'iv' => $this->getIv(),
'key_infos' => $this->getKeyInfos(),
'type' => $this->getType(),
'before' => (new \DateTimeImmutable('now'))->getTimestamp(),
];
}
public function saveHistory(): void {}
public static function generatePrefix(): string
{