mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-12 21:44:21 -06:00
Normalize filenames and titles to NFC
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import logging
|
||||
import shutil
|
||||
import unicodedata
|
||||
from os import PathLike
|
||||
from os import utime
|
||||
from pathlib import Path
|
||||
from subprocess import CompletedProcess
|
||||
@@ -16,6 +18,14 @@ def _coerce_to_path(
|
||||
return Path(source).resolve(), Path(dest).resolve()
|
||||
|
||||
|
||||
def normalize_nfc(value: str | PathLike[str] | None) -> str | None:
|
||||
"""Return NFC-normalized string for filesystem-safe comparisons."""
|
||||
|
||||
if value is None:
|
||||
return None
|
||||
return unicodedata.normalize("NFC", str(value))
|
||||
|
||||
|
||||
def copy_basic_file_stats(source: Path | str, dest: Path | str) -> None:
|
||||
"""
|
||||
Copies only the m_time and a_time attributes from source to destination.
|
||||
|
||||
Reference in New Issue
Block a user