Merge branch 'dev' into feature-use-celery

This commit is contained in:
shamoon
2022-10-03 18:00:54 -07:00
committed by GitHub
23 changed files with 714 additions and 446 deletions

View File

@@ -111,14 +111,16 @@ class Consumer(LoggingMixin):
def pre_check_duplicate(self):
with open(self.path, "rb") as f:
checksum = hashlib.md5(f.read()).hexdigest()
if Document.objects.filter(
existing_doc = Document.objects.filter(
Q(checksum=checksum) | Q(archive_checksum=checksum),
).exists():
)
if existing_doc.exists():
if settings.CONSUMER_DELETE_DUPLICATES:
os.unlink(self.path)
self._fail(
MESSAGE_DOCUMENT_ALREADY_EXISTS,
f"Not consuming {self.filename}: It is a duplicate.",
f"Not consuming {self.filename}: It is a duplicate of"
f" {existing_doc.get().title} (#{existing_doc.get().pk})",
)
def pre_check_directories(self):

View File

@@ -127,10 +127,10 @@ def settings_values_check(app_configs, **kwargs):
Error(f'OCR output type "{settings.OCR_OUTPUT_TYPE}" is not valid'),
)
if settings.OCR_MODE not in {"force", "skip", "redo_ocr"}:
if settings.OCR_MODE not in {"force", "skip", "redo", "skip_noarchive"}:
msgs.append(Error(f'OCR output mode "{settings.OCR_MODE}" is not valid'))
if settings.OCR_CLEAN not in {"clean", "clean_final"}:
if settings.OCR_CLEAN not in {"clean", "clean-final", "none"}:
msgs.append(Error(f'OCR clean mode "{settings.OCR_CLEAN}" is not valid'))
return msgs

View File

@@ -322,6 +322,7 @@ DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(DATA_DIR, "db.sqlite3"),
"OPTIONS": {},
},
}
@@ -343,21 +344,18 @@ if os.getenv("PAPERLESS_DBHOST"):
# Leave room for future extensibility
if os.getenv("PAPERLESS_DBENGINE") == "mariadb":
engine = "django.db.backends.mysql"
options = {"read_default_file": "/etc/mysql/my.cnf"}
options = {"read_default_file": "/etc/mysql/my.cnf", "charset": "utf8mb4"}
else: # Default to PostgresDB
engine = "django.db.backends.postgresql_psycopg2"
options = {"sslmode": os.getenv("PAPERLESS_DBSSLMODE", "prefer")}
DATABASES["default"]["ENGINE"] = engine
for key, value in options.items():
DATABASES["default"]["OPTIONS"][key] = value
DATABASES["default"]["OPTIONS"].update(options)
if os.getenv("PAPERLESS_DB_TIMEOUT") is not None:
_new_opts = {"timeout": float(os.getenv("PAPERLESS_DB_TIMEOUT"))}
if "OPTIONS" in DATABASES["default"]:
DATABASES["default"]["OPTIONS"].update(_new_opts)
else:
DATABASES["default"]["OPTIONS"] = _new_opts
DATABASES["default"]["OPTIONS"].update(
{"timeout": float(os.getenv("PAPERLESS_DB_TIMEOUT"))},
)
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

View File

@@ -1,7 +1,7 @@
from typing import Final
from typing import Tuple
__version__: Final[Tuple[int, int, int]] = (1, 9, 0)
__version__: Final[Tuple[int, int, int]] = (1, 9, 2)
# Version string like X.Y.Z
__full_version_str__: Final[str] = ".".join(map(str, __version__))
# Version string like X.Y

View File

@@ -11,5 +11,6 @@ def text_consumer_declaration(sender, **kwargs):
"mime_types": {
"text/plain": ".txt",
"text/csv": ".csv",
"application/csv": ".csv",
},
}