From d57ed0341712f47b69abf9dc870a68c40f900f2e Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 20 Feb 2020 14:48:19 +0200 Subject: [PATCH] Make sure we don't upload the same file twice. --- .../migrations/0010_auto_20200220_1248.py | 19 +++++++++++++++++++ django_etesync/models.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 django_etesync/migrations/0010_auto_20200220_1248.py diff --git a/django_etesync/migrations/0010_auto_20200220_1248.py b/django_etesync/migrations/0010_auto_20200220_1248.py new file mode 100644 index 0000000..0c08ed0 --- /dev/null +++ b/django_etesync/migrations/0010_auto_20200220_1248.py @@ -0,0 +1,19 @@ +# Generated by Django 3.0.3 on 2020-02-20 12:48 + +from django.db import migrations, models +import django_etesync.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('django_etesync', '0009_auto_20200220_1220'), + ] + + operations = [ + migrations.AlterField( + model_name='collectionitemchunk', + name='chunkFile', + field=models.FileField(max_length=150, unique=True, upload_to=django_etesync.models.chunk_directory_path), + ), + ] diff --git a/django_etesync/models.py b/django_etesync/models.py index 0cefbee..37c0dc1 100644 --- a/django_etesync/models.py +++ b/django_etesync/models.py @@ -65,7 +65,7 @@ class CollectionItemChunk(models.Model): max_length=44, validators=[UidValidator]) item = models.ForeignKey(CollectionItem, related_name='chunks', on_delete=models.CASCADE) order = models.CharField(max_length=100, blank=False, null=False) - chunkFile = models.FileField(upload_to=chunk_directory_path, max_length=150) + chunkFile = models.FileField(upload_to=chunk_directory_path, max_length=150, unique=True) class Meta: unique_together = ('item', 'order')