mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Add local file crawler
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user