be case-sensitive on windows/macos (closes #781);

on Windows and Macos, most filesystems are case-insensitive,
which can lead to dangerous situations

one example is when another program (not copyparty or its UI) wants to
rename a file from `Foo` to `foo`; the program will probably start by
checking if `foo` exists and then delete it, however this would match
`Foo` and confuse the program into deleting the wrong file

fix this by adding a VERY EXPENSIVE detector to prevent this,
by listing the parent folder and checking if the case matches

this check will auto-enable when a case-insensitive FS is detected on
startup, but option `casechk` (global or volflag) can override this
This commit is contained in:
ed 2025-09-14 23:39:46 +00:00
parent 3a2381ff2d
commit 8b66874b85
8 changed files with 103 additions and 7 deletions

View file

@ -17,7 +17,7 @@ from argparse import Namespace
import jinja2
from copyparty.__init__ import MACOS, WINDOWS, E
from copyparty.__init__ import ANYWIN, MACOS, WINDOWS, E
J2_ENV = jinja2.Environment(loader=jinja2.BaseLoader) # type: ignore
J2_FILES = J2_ENV.from_string("{{ files|join('\n') }}\nJ2EOT")
@ -185,6 +185,7 @@ class Cfg(Namespace):
E=E,
auth_ord="idp,ipu",
bup_ck="sha512",
casechk="a" if ANYWIN or MACOS else "n",
chmod_d="755",
cookie_cmax=8192,
cookie_nmax=50,