Skip to content

Commit

Permalink
add extra context for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed May 6, 2023
1 parent 74ef92f commit c2a3c3a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions syncthing_paranoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dataclasses import dataclass
from subprocess import check_output
from pathlib import Path
from typing import Iterator
from typing import Iterator, Any
import os
import re
import shutil
Expand All @@ -17,6 +17,7 @@
# make android friendly https://stackoverflow.com/a/48182875/706389
# TODO hmm it actually might be fine these days?
# since android is using f2fs now? https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits
# 20230506 hmm, ok so "?" is definitely not working -- tried creating a file on PC, didn't sync on either pixel of samsung device
ANDROID = r'''|\?*<\":>+\[\]/'"'''
MISC = ''.join([
'·', # not sure what's a better way to deal with it?
Expand All @@ -29,6 +30,7 @@
class Error:
path: Path
info: str
extra: Any = None


def check(syncthing: Path) -> Iterator[Error]:
Expand All @@ -53,7 +55,8 @@ def check(syncthing: Path) -> Iterator[Error]:
## check filenames potentially unfriendly to Android
for x in xx:
if re.search(f'[{FORBIDDEN}]', x):
yield Error(path=Path(r) / x, info='file name contains special characters, might be bad for Windows/Android')
contained = {c for c in FORBIDDEN if c in x}
yield Error(path=Path(r) / x, info='file name contains special characters, might be bad for Windows/Android', extra=contained)
##


Expand Down

0 comments on commit c2a3c3a

Please sign in to comment.