From 1dc6043061d45b878caf0eb5bcaa41ab6d0adbde Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Thu, 5 Oct 2017 21:36:12 -0600 Subject: [PATCH] Implement note deletion --- itemmanager.py | 6 ++++++ sn-fs.py | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/itemmanager.py b/itemmanager.py index b8f3708..a9fc204 100644 --- a/itemmanager.py +++ b/itemmanager.py @@ -79,6 +79,12 @@ class ItemManager: content=content) return 0 + def deleteNote(self, uuid): + item = self.items[uuid] + item['deleted'] = True + item['dirty'] = True + self.syncItems() + def __init__(self, username, password): self.standard_notes = StandardNotesAPI(username, password) self.syncItems() diff --git a/sn-fs.py b/sn-fs.py index 691da2c..2a15b94 100644 --- a/sn-fs.py +++ b/sn-fs.py @@ -12,7 +12,6 @@ from datetime import datetime from fuse import FUSE, FuseOSError, Operations, LoggingMixIn from itemmanager import ItemManager - class StandardNotesFS(LoggingMixIn, Operations): def __init__(self, path='.'): self.item_manager = ItemManager('tanner@domain.com', 'complexpass') @@ -87,6 +86,18 @@ class StandardNotesFS(LoggingMixIn, Operations): self.item_manager.createNote(note_name, now) return 0 + def unlink(self, path): + self.notes = self.item_manager.getNotes() + + path_parts = path.split('/') + note_name = path_parts[1] + note = self.notes[note_name] + uuid = note['uuid'] + + self.item_manager.deleteNote(uuid) + + return 0 + def chmod(self, path, mode): return 0 @@ -114,9 +125,6 @@ class StandardNotesFS(LoggingMixIn, Operations): def truncate(self, path, length, fh=None): return 0 - def unlink(self, path): - return 0 - def utimens(self, path, times=None): return 0