Skip to content

Commit

Permalink
Ensure decompilers are unique
Browse files Browse the repository at this point in the history
  • Loading branch information
negasora committed Nov 28, 2023
1 parent 353b387 commit 4236d7a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions explorer/migrations/0019_decompiler_unique_decompiler_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.19 on 2023-11-28 23:22

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('explorer', '0018_alter_decompilationrequest_decompiler'),
]

operations = [
migrations.AddConstraint(
model_name='decompiler',
constraint=models.UniqueConstraint(fields=('name', 'version', 'revision', 'url'), name='unique_decompiler_info'),
),
]
6 changes: 5 additions & 1 deletion explorer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def __str__(self):
return f'Binary: {self.hash}'


#TODO: unique constraint on name, version, revision, url
class Decompiler(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=255)
Expand All @@ -55,6 +54,11 @@ class Decompiler(models.Model):
featured = models.BooleanField('Featured on homepage', default=False)
created = models.DateTimeField(default=timezone.now, editable=False)

class Meta:
constraints = [
UniqueConstraint(fields=['name', 'version', 'revision', 'url'], name='unique_decompiler_info')
]

def __str__(self):
if len(self.revision) > 0:
return f'Decompiler: {self.name} {self.version} {self.revision[:8]}'
Expand Down

0 comments on commit 4236d7a

Please sign in to comment.