diff --git a/src/documents/__init__.py b/src/documents/__init__.py index dd8c76d19..861c45185 100644 --- a/src/documents/__init__.py +++ b/src/documents/__init__.py @@ -1,5 +1,4 @@ # this is here so that django finds the checks. -from documents.checks import changed_password_check from documents.checks import parser_check -__all__ = ["changed_password_check", "parser_check"] +__all__ = ["parser_check"] diff --git a/src/documents/migrations/1003_mime_types.py b/src/documents/migrations/1003_mime_types.py index 4c7ddb492..10cf4f635 100644 --- a/src/documents/migrations/1003_mime_types.py +++ b/src/documents/migrations/1003_mime_types.py @@ -1,51 +1,8 @@ # Generated by Django 3.1.3 on 2020-11-20 11:21 -from pathlib import Path -import magic -from django.conf import settings from django.db import migrations from django.db import models -from paperless.db import GnuPG - -STORAGE_TYPE_UNENCRYPTED = "unencrypted" -STORAGE_TYPE_GPG = "gpg" - - -def source_path(self) -> Path: - if self.filename: - fname: str = str(self.filename) - else: - fname = f"{self.pk:07}.{self.file_type}" - if self.storage_type == STORAGE_TYPE_GPG: - fname += ".gpg" - - return Path(settings.ORIGINALS_DIR) / fname - - -def add_mime_types(apps, schema_editor): - Document = apps.get_model("documents", "Document") - documents = Document.objects.all() - - for d in documents: - with Path(source_path(d)).open("rb") as f: - if d.storage_type == STORAGE_TYPE_GPG: - data = GnuPG.decrypted(f) - else: - data = f.read(1024) - - d.mime_type = magic.from_buffer(data, mime=True) - d.save() - - -def add_file_extensions(apps, schema_editor): - Document = apps.get_model("documents", "Document") - documents = Document.objects.all() - - for d in documents: - d.file_type = Path(d.filename).suffix.lstrip(".") - d.save() - class Migration(migrations.Migration): dependencies = [ @@ -59,7 +16,7 @@ class Migration(migrations.Migration): field=models.CharField(default="-", editable=False, max_length=256), preserve_default=False, ), - migrations.RunPython(add_mime_types, migrations.RunPython.noop), + migrations.RunPython(migrations.RunPython.noop, migrations.RunPython.noop), # This operation is here so that we can revert the entire migration: # By allowing this field to be blank and null, we can revert the # remove operation further down and the database won't complain about @@ -84,7 +41,7 @@ class Migration(migrations.Migration): blank=True, ), ), - migrations.RunPython(migrations.RunPython.noop, add_file_extensions), + migrations.RunPython(migrations.RunPython.noop, migrations.RunPython.noop), migrations.RemoveField( model_name="document", name="file_type", diff --git a/src/documents/migrations/1077_remove_document_storage_type.py b/src/documents/migrations/1077_remove_document_storage_type.py new file mode 100644 index 000000000..c74367e9f --- /dev/null +++ b/src/documents/migrations/1077_remove_document_storage_type.py @@ -0,0 +1,16 @@ +# Generated by Django 5.2.9 on 2026-01-21 22:16 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("documents", "1076_alter_paperlesstask_task_name"), + ] + + operations = [ + migrations.RemoveField( + model_name="document", + name="storage_type", + ), + ]