Added tests for backend watching tree diff, fixed bugs.

This commit is contained in:
Leo Vasanko
2023-11-12 21:10:20 +00:00
parent c31fb24752
commit 12c954394a
3 changed files with 85 additions and 3 deletions

View File

@@ -120,6 +120,9 @@ class FileEntry(msgspec.Struct, array_like=True):
size: int
isfile: int
def __repr__(self):
return self.key or "FileEntry()"
class Update(msgspec.Struct, array_like=True):
...
@@ -137,6 +140,10 @@ class UpdIns(Update, tag="i"):
items: list[FileEntry]
class UpdateMessage(msgspec.Struct):
update: list[UpdKeep | UpdDel | UpdIns]
class Space(msgspec.Struct):
disk: int
free: int

View File

@@ -282,13 +282,11 @@ def format_update(old, new):
del_count = 0
rest = new[nidx:]
while old[oidx] not in rest:
while oidx < len(old) and old[oidx] not in rest:
del_count += 1
oidx += 1
if del_count:
update.append(UpdDel(del_count))
oidx += 1
continue
insert_items = []