fix: detect WebDAV year folder anywhere in path (Faturas/2025/…)
This commit is contained in:
1 parent
f381af9c60
commit
1617be3aee
2 files changed
+6
-9
No files matched your search
@@ -95,12 +95,9 @@ def parse_webdav_message_key(message_key: str) -> str | None:
|
||||
|
||||
|
||||
def webdav_year_folder(relative_path: str) -> str | None:
|
||||
parts = [part for part in relative_path.strip("/").split("/") if part]
|
||||
if not parts:
|
||||
return None
|
||||
head = parts[0]
|
||||
if len(head) == 4 and head.isdigit():
|
||||
return head
|
||||
for part in relative_path.strip("/").split("/"):
|
||||
if len(part) == 4 and part.isdigit():
|
||||
return part
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -74,9 +74,9 @@ def test_webdav_message_key_roundtrip():
|
||||
|
||||
def test_webdav_path_matches_min_year():
|
||||
assert webdav_path_matches_min_year("2025/invoice.pdf", 2025)
|
||||
assert webdav_path_matches_min_year("2026/a.pdf", 2025)
|
||||
assert webdav_path_matches_min_year("2027/future.pdf", 2025)
|
||||
assert not webdav_path_matches_min_year("2024/old.pdf", 2025)
|
||||
assert webdav_path_matches_min_year("Faturas/2026/08/a.pdf", 2025)
|
||||
assert webdav_path_matches_min_year("Faturas/2027/future.pdf", 2025)
|
||||
assert not webdav_path_matches_min_year("Faturas/2024/old.pdf", 2025)
|
||||
assert not webdav_path_matches_min_year("misc/file.pdf", 2025)
|
||||
assert webdav_path_matches_min_year("2024/old.pdf", None)
|
||||
|
||||
|
||||
Reference in new issue
Block a user