Commit f623cb65 authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

fixes #16 soft-delete bug with re-upload

parent befe0d40
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -922,7 +922,9 @@ def upload_infos(user: User, sha256_hash: str) -> Dict:
    infos = {"status": "not available", "id": None, "available_chunks": []}
    if re.match("[A-Fa-f0-9]{64}", sha256_hash) is not None:
        try:
            file_instance = File.objects.get(hash=sha256_hash, owner=user)
            file_instance = File.objects.get(
                hash=sha256_hash, owner=user, deleted_at__isnull=True
            )
            infos["status"] = "available"
            infos["id"] = file_instance.id
        except File.DoesNotExist:
+5 −0
Original line number Diff line number Diff line
@@ -185,6 +185,11 @@ def upload_partial(request: HttpRequest) -> HttpResponse:
        file_name = base64.b64decode(request.headers["X-file-name"]).decode("utf-8")
        chunk_number, total_chunks = request.headers["X-file-chunk"].split("/")
        file_instance = models.File.objects.get(hash=file_hash, owner=user)
        # Rise from your grave !
        if file_instance.deleted_at:
            file_instance.deleted_at = None
            file_instance.original_name = file_name
            file_instance.save()
        if origin_dir:
            collection = _collection_from_origin_dir(origin_dir, user)
            collection.resources.add(file_instance)