[gnome-notes/fix-selection-bar: 3/3] manager: Fix restore from trash




commit 00ee27c963d31148c957925fac01600a8000d15d
Author: Isaque Galdino <igaldino gmail com>
Date:   Tue Aug 11 23:48:56 2020 -0300

    manager: Fix restore from trash
    
    GNOME Notes keeps notes references as its path in the file system. That
    is known internally as uuid.
    
    When a note is moved to trash, although its path changes, to add the
    ".Trash" directory path, its uuid does not.
    
    When GNOME Notes was restoring a note from trash it was using the new
    path, with ".Trash" directory path in it, instead of the uuid.
    
    This commit changes that, so GNOME Notes now only uses the uuid.

 src/libbiji/biji-manager.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/libbiji/biji-manager.c b/src/libbiji/biji-manager.c
index 49909378..e20c4e44 100644
--- a/src/libbiji/biji-manager.c
+++ b/src/libbiji/biji-manager.c
@@ -565,12 +565,12 @@ on_item_trashed_cb (BijiItem *item, BijiManager *self)
 static void
 on_item_restored_cb (BijiItem *item, gchar *old_uuid, BijiManager *manager)
 {
+  const char *path = biji_item_get_uuid (item);
   if (BIJI_IS_NOTE_OBJ (item))
     biji_note_obj_save_note (BIJI_NOTE_OBJ (item));
 
-  g_hash_table_insert (manager->items,
-                       (gpointer) biji_item_get_uuid (item), item);
-  g_hash_table_remove (manager->archives, old_uuid);
+  g_hash_table_insert (manager->items, (gpointer) path, item);
+  g_hash_table_remove (manager->archives, path);
 
   biji_manager_notify_changed (manager,
                                BIJI_ARCHIVED_ITEMS,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]