Add move operation, fix fuse server

This commit is contained in:
Andrew Mulbrook 2026-03-28 13:25:25 -05:00
parent 41480a39c9
commit 6470aee802
5 changed files with 90 additions and 45 deletions

View file

@ -5,7 +5,7 @@ Implements BlobNote, TreeNote, and Trove protocols defined in trove.py.
Depends on db.py (Sqlite3Trove) for storage.
"""
from typing import Optional, Iterator
from typing import Optional, Iterator, override
from pathlib import Path
import datetime as dt
import uuid
@ -78,6 +78,7 @@ class NoteImpl(Note):
"""Create a new child note."""
content = content if content is not None else b""
object_id = self._db.write_blob(data=content, object_id=None, dtype=mime, executable=executable, hidden=hidden)
self._db.link(self._object_id, name, object_id)
# TODO fix this
if mime == 'inode/directory':
return TreeNoteImpl(self._parent, object_id)
@ -139,7 +140,7 @@ class TreeNoteImpl(NoteImpl, TreeNote):
# Trove
# ---------------------------------------------------------------------------
class TroveImpl:
class TroveImpl(Trove):
"""
Concrete Trove: top-level API backed by a Sqlite3Trove database.
@ -179,6 +180,17 @@ class TroveImpl:
return TreeNoteImpl(self, note_id)
return NoteImpl(self, note_id)
@override
def move(self, src_parent: Note, src_name: str, dst_parent: Note, dst_name: str, overwrite: bool):
"""Move a child note to a new location."""
src_note = src_parent.child(src_name)
if not isinstance(src_note, NoteImpl):
raise tr.ErrorBadType("not a valid DB note")
if not isinstance(dst_parent, NoteImpl):
raise tr.ErrorBadType("not a valid DB note")
self._db.link(dst_parent.object_id, dst_name, src_note.object_id)
self._db.unlink(src_parent.object_id, src_name)
def create_blob(self, data: bytes | None = None,
dtype: str = "application/octet-stream") -> Note:
"""Create a new blob object and return a BlobNote for it."""