From b23765b998449fdf9898d4e1a187c5b2baa21837 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Mon, 9 Oct 2017 23:07:54 -0600 Subject: [PATCH] Implement note renaming --- itemmanager.py | 6 ++++++ sn_fuse.py | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/itemmanager.py b/itemmanager.py index 0e2fa3c..68d2d79 100644 --- a/itemmanager.py +++ b/itemmanager.py @@ -84,6 +84,12 @@ class ItemManager: content=content) self.syncItems() + def renameNote(self, uuid, new_note_name): + item = self.items[uuid] + item['content']['title'] = new_note_name + item['dirty'] = True + self.syncItems() + def deleteNote(self, uuid): item = self.items[uuid] item['deleted'] = True diff --git a/sn_fuse.py b/sn_fuse.py index 6ce0d77..7347b62 100644 --- a/sn_fuse.py +++ b/sn_fuse.py @@ -66,7 +66,6 @@ class StandardNotesFUSE(LoggingMixIn, Operations): def truncate(self, path, length, fh=None): note, uuid = self._pathToNote(path) text = note['text'][:length] - self.item_manager.writeNote(uuid, text) def write(self, path, data, offset, fh): @@ -79,7 +78,6 @@ class StandardNotesFUSE(LoggingMixIn, Operations): raise FuseOSError(errno.EIO) self.item_manager.writeNote(uuid, text) - return len(data) def create(self, path, mode): @@ -98,7 +96,6 @@ class StandardNotesFUSE(LoggingMixIn, Operations): def unlink(self, path): note, uuid = self._pathToNote(path) - self.item_manager.deleteNote(uuid) return 0 @@ -108,10 +105,16 @@ class StandardNotesFUSE(LoggingMixIn, Operations): def utimens(self, path, times=None): note, uuid = self._pathToNote(path) - self.item_manager.touchNote(uuid) return 0 + def rename(self, old, new): + note, uuid = self._pathToNote(old) + new_path_parts = new.split('/') + new_note_name = new_path_parts[1] + self.item_manager.renameNote(uuid, new_note_name) + return 0 + def chmod(self, path, mode): return 0 @@ -124,9 +127,6 @@ class StandardNotesFUSE(LoggingMixIn, Operations): def readlink(self, path): return 0 - def rename(self, old, new): - return 0 - def rmdir(self, path): return 0