Uids: change uids to be much shorter and base62 for non-chunks.
This commit is contained in:
parent
3beb7ac4bb
commit
d587f8185b
29
django_etesync/migrations/0020_auto_20200310_1438.py
Normal file
29
django_etesync/migrations/0020_auto_20200310_1438.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# Generated by Django 3.0.3 on 2020-03-10 14:38
|
||||||
|
|
||||||
|
import django.core.validators
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('django_etesync', '0019_collectionmember'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='collection',
|
||||||
|
name='uid',
|
||||||
|
field=models.CharField(db_index=True, max_length=44, validators=[django.core.validators.RegexValidator(message='Not a valid UID', regex='[a-zA-Z0-9]{24}')]),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='collectionitem',
|
||||||
|
name='uid',
|
||||||
|
field=models.CharField(db_index=True, max_length=44, validators=[django.core.validators.RegexValidator(message='Not a valid UID', regex='[a-zA-Z0-9]{24}')]),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='collectionitemchunk',
|
||||||
|
name='uid',
|
||||||
|
field=models.CharField(db_index=True, max_length=44, validators=[django.core.validators.RegexValidator(message='Expected a 256bit base64url.', regex='^[a-zA-Z0-9\\-_]{43}=?$')]),
|
||||||
|
),
|
||||||
|
]
|
24
django_etesync/migrations/0021_auto_20200310_1439.py
Normal file
24
django_etesync/migrations/0021_auto_20200310_1439.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Generated by Django 3.0.3 on 2020-03-10 14:39
|
||||||
|
|
||||||
|
import django.core.validators
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('django_etesync', '0020_auto_20200310_1438'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='collection',
|
||||||
|
name='uid',
|
||||||
|
field=models.CharField(db_index=True, max_length=44, validators=[django.core.validators.RegexValidator(message='Not a valid UID', regex='[a-zA-Z0-9]')]),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='collectionitem',
|
||||||
|
name='uid',
|
||||||
|
field=models.CharField(db_index=True, max_length=44, validators=[django.core.validators.RegexValidator(message='Not a valid UID', regex='[a-zA-Z0-9]')]),
|
||||||
|
),
|
||||||
|
]
|
@ -20,7 +20,8 @@ from django.core.validators import RegexValidator
|
|||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
|
|
||||||
|
|
||||||
UidValidator = RegexValidator(regex=r'[a-zA-Z0-9\-_=]{43}', message='Not a valid UID. Expected a 256bit base64url.')
|
Base64Url256BitValidator = RegexValidator(regex=r'^[a-zA-Z0-9\-_]{43}=?$', message='Expected a 256bit base64url.')
|
||||||
|
UidValidator = RegexValidator(regex=r'[a-zA-Z0-9]', message='Not a valid UID')
|
||||||
|
|
||||||
|
|
||||||
class Collection(models.Model):
|
class Collection(models.Model):
|
||||||
@ -61,7 +62,7 @@ def chunk_directory_path(instance, filename):
|
|||||||
|
|
||||||
class CollectionItemChunk(models.Model):
|
class CollectionItemChunk(models.Model):
|
||||||
uid = models.CharField(db_index=True, blank=False, null=False,
|
uid = models.CharField(db_index=True, blank=False, null=False,
|
||||||
max_length=44, validators=[UidValidator])
|
max_length=44, validators=[Base64Url256BitValidator])
|
||||||
item = models.ForeignKey(CollectionItem, related_name='chunks', on_delete=models.CASCADE)
|
item = models.ForeignKey(CollectionItem, related_name='chunks', on_delete=models.CASCADE)
|
||||||
order = models.CharField(max_length=100, blank=False, null=False)
|
order = models.CharField(max_length=100, blank=False, null=False)
|
||||||
chunkFile = models.FileField(upload_to=chunk_directory_path, max_length=150, unique=True)
|
chunkFile = models.FileField(upload_to=chunk_directory_path, max_length=150, unique=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user