mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Update random_bytes length in filename and prefix generation
The size of the random byte string used in the generateFilename method of StoredObjectVersion has been reduced from 16 to 8. Conversely, the size of the random byte string used in the generatePrefix method of StoredObject has been increased from 8 to 32. The naming generation fit better with the usage, as 16bytes are generated for each file (more version), and less for the version.
This commit is contained in:
parent
2feea24c41
commit
cb90261309
@ -354,7 +354,7 @@ class StoredObject implements Document, TrackCreationInterface
|
||||
public static function generatePrefix(): string
|
||||
{
|
||||
try {
|
||||
return base_convert(bin2hex(random_bytes(8)), 16, 36);
|
||||
return base_convert(bin2hex(random_bytes(32)), 16, 36);
|
||||
} catch (RandomException $e) {
|
||||
return uniqid(more_entropy: true);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ class StoredObjectVersion implements TrackCreationInterface
|
||||
public static function generateFilename(StoredObjectVersion $storedObjectVersion): string
|
||||
{
|
||||
try {
|
||||
$suffix = base_convert(bin2hex(random_bytes(16)), 16, 36);
|
||||
$suffix = base_convert(bin2hex(random_bytes(8)), 16, 36);
|
||||
} catch (RandomException $e) {
|
||||
$suffix = uniqid(more_entropy: true);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ final readonly class ChillDocumentManager implements DocumentManagerInterface
|
||||
throw new \Error('Unknown mimetype for stored document.');
|
||||
}
|
||||
|
||||
return sprintf('%s.%s', $document->getFilename(), reset($exts));
|
||||
return sprintf('%s.%s', $document->getPrefix(), reset($exts));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user