Added tests for backend watching tree diff, fixed bugs.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
Reference in New Issue
Block a user