Skip to content

Commit

Permalink
changes to lock2
Browse files Browse the repository at this point in the history
  • Loading branch information
joerivrij committed Oct 23, 2023
1 parent ca47dc1 commit afc7702
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/drc/api/serializers/bestandsdeel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

class BestandsDeelSerializer(serializers.HyperlinkedModelSerializer):
lock = serializers.CharField(
read_only=True,
source="canonical.lock",
help_text="Hash string, which represents id of the lock of related informatieobject",
)

Expand Down
8 changes: 3 additions & 5 deletions src/drc/api/serializers/enkelvoudig_informatieobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _create_bestandsdeel(self, full_size, canonical):
for i in range(parts):
chunk_size = min(settings.CHUNK_SIZE, full_size)
BestandsDeel.objects.create(
informatieobject=canonical, omvang=chunk_size, volgnummer=i + 1
informatieobject=canonical, omvang=chunk_size, volgnummer=i + 1, lock=canonical.lock
)
full_size -= chunk_size

Expand Down Expand Up @@ -266,10 +266,6 @@ def create(self, validated_data):
eio.ondertekening = ondertekening
eio.save()

# large file process
if not eio.inhoud and eio.bestandsomvang and eio.bestandsomvang > 0:
self._create_bestandsdeel(validated_data["bestandsomvang"], canonical)

# create empty file if size == 0
if eio.bestandsomvang == 0:
eio.inhoud.save("empty_file", ContentFile(""))
Expand Down Expand Up @@ -381,6 +377,8 @@ def create(self, validated_data):
# lock document if it is a large file upload
if not eio.inhoud and eio.bestandsomvang and eio.bestandsomvang > 0:
eio.canonical.lock = uuid.uuid4().hex
# large file process
self._create_bestandsdeel(validated_data["bestandsomvang"], eio.canonical)
eio.canonical.save()
return eio

Expand Down

0 comments on commit afc7702

Please sign in to comment.