mirror of
https://github.com/Garmelon/PFERD.git
synced 2026-04-12 15:35:05 +02:00
Add local file crawler
This commit is contained in:
parent
273d56c39a
commit
60cd9873bc
7 changed files with 104 additions and 13 deletions
|
|
@ -28,6 +28,15 @@ class MarkConflictException(Exception):
|
|||
collides_with: PurePath
|
||||
|
||||
|
||||
# TODO Use PurePath.is_relative_to when updating to 3.9
|
||||
def is_relative_to(a: PurePath, b: PurePath) -> bool:
|
||||
try:
|
||||
a.relative_to(b)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
class Report:
|
||||
"""
|
||||
A report of a synchronization. Includes all files found by the crawler, as
|
||||
|
|
@ -53,7 +62,7 @@ class Report:
|
|||
if path == known_path:
|
||||
raise MarkDuplicateException(path)
|
||||
|
||||
if path.relative_to(known_path) or known_path.relative_to(path):
|
||||
if is_relative_to(path, known_path) or is_relative_to(known_path, path):
|
||||
raise MarkConflictException(path, known_path)
|
||||
|
||||
self.known_files.add(path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue