From 23e7e4c67ded04611d71e7c89f3a4ea2d965de3c Mon Sep 17 00:00:00 2001 From: teamcons Date: Wed, 13 May 2026 17:59:24 +0200 Subject: [PATCH 1/2] Storage: Move to a domain name --- src/Services/Storage.vala | 59 ++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/src/Services/Storage.vala b/src/Services/Storage.vala index a8c7f9a4..66588a4e 100644 --- a/src/Services/Storage.vala +++ b/src/Services/Storage.vala @@ -17,8 +17,8 @@ public class Jorts.Storage : Object { private const string FILENAME = "saved_state.json"; - private string data_directory; - private string storage_file; + private File datadir; + private string savefile_path; /** * Convenience property wrapping load() and save() @@ -30,38 +30,45 @@ public class Jorts.Storage : Object { /*************************************************/ construct { + var path_data = GLib.Path.build_path (Path.DIR_SEPARATOR_S, Environment.get_user_data_dir (), APP_ID); + datadir = File.new_for_path (path_data); + savefile_path = GLib.Path.build_path (Path.DIR_SEPARATOR_S, path_data, FILENAME); -#if WINDOWS - // In Windows we arent in a sandbox, so we need to have some courtesy and not dump in the allfolder - data_directory = GLib.Path.build_path("/", Environment.get_user_data_dir (), APP_ID); -#else - data_directory = Environment.get_user_data_dir (); -#endif + ensure_datadir (); - storage_file = GLib.Path.build_path("/", data_directory, FILENAME); - print (storage_file); + // TODO: Remove the below cruft after a while + var old_storage_path = GLib.Path.build_path (Path.DIR_SEPARATOR_S, Environment.get_user_data_dir (), FILENAME); + var old_storage_file = File.new_for_path (old_storage_path); + var savefile = File.new_for_path (savefile_path); - check_if_stash (); + if (old_storage_file.query_exists ()) { + try { + old_storage_file.move (savefile, GLib.FileCopyFlags.OVERWRITE); + print ("Sucessfully moved old storage"); + + } catch (Error e) { + warning ("Failed to move storage %s\n", e.message); + } + } } /*************************************************/ /** * Persistently check for the data directory and create if there is none */ - private void check_if_stash () { + private void ensure_datadir () { debug ("do we have a data directory?"); - var dir = File.new_for_path (data_directory); - - if (dir.query_exists ()) { + if (datadir.query_exists ()) { + debug ("Yes, nevermind"); return; } try { - dir.make_directory_with_parents (); + datadir.make_directory_with_parents (); debug ("yes we do now"); } catch (Error e) { - warning ("Failed to prepare target data directory %s\n", e.message); + warning ("Failed to prepare target data directory %s", e.message); } } @@ -70,21 +77,21 @@ public class Jorts.Storage : Object { * Converts a Json.Node into a string and take care of saving it */ public void save (Json.Array json_data) { - debug("Writing..."); - check_if_stash (); + ensure_datadir (); + debug("Writing %ui elements... (Should be same number as sticky notes)", json_data.get_length ()); try { var generator = new Json.Generator (); var node = new Json.Node (Json.NodeType.ARRAY); node.set_array (json_data); generator.set_root (node); - generator.to_file (storage_file); + generator.to_file (savefile_path); } catch (Error e) { - warning ("[STORAGE] Failed to save notes %s", e.message); + warning ("Failed to save notes %s", e.message); } - print ("\n (Everything saved)"); + print ("\n (%ui notes saved)", json_data.get_length ()); } /*************************************************/ @@ -92,21 +99,21 @@ public class Jorts.Storage : Object { * Grab from storage, into a Json.Node we can parse. Insist if necessary */ public Json.Array load () { - debug("Loading from storage letsgo"); - check_if_stash (); + debug ("Loading from storage letsgo"); var parser = new Json.Parser (); var array = new Json.Array (); try { - parser.load_from_mapped_file (storage_file); + parser.load_from_mapped_file (savefile_path); var node = parser.get_root (); array = node.get_array (); } catch (Error e) { - warning ("Failed to load from storage " + e.message.to_string()); + warning ("Failed to load from storage %s", e.message); } + debug ("Retrieved %ui elements", array.get_length ()); return array; } } From dfe48c3d51e264f01775f3ac4d4fcae07c1b43dc Mon Sep 17 00:00:00 2001 From: teamcons Date: Wed, 13 May 2026 19:17:39 +0200 Subject: [PATCH 2/2] Readmne --- README.md | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 94b7e375..d0bad147 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ The app is destined to stay simple. If anything there is already too much in the Roadmap: - Document stuff - Fix an annoying memory leak where deleted notes linger in memory - - Bin the whole saving infra and use Gtk 4.24 save-state new thing + - Use Gtk 4.24 save-state new thing if it ever lands - More icon variants - Better list/bullets - Co-maintainers would be nice @@ -68,25 +68,51 @@ On the right you can donate to various contributors: ## 💾 Notes Storage +"saved_state.json" contains all notes in JSON format. The structure is quite simple, it is an array of objects, each representing the data of a sticky note -Notes are stored in `~/.var/app/io.github.elly_code.jorts/data` -if from flathub, `~/.var/app/io.github.ellie_commons.jorts/data` +The app reads from it only during startup (rest of the time it writes in) so you could quite easily swap it up to swap between sets of notes. + +The app writes to it everytime there is a sticky note change + + + +### If installed from flathub (if you are not on elementary OS) -You can get it all by entering in a terminal: +You can get it all by entering in the search bar of your file explorer: + +~/.var/app/io.github.ellie_commons.jorts/data/io.github.ellie_commons.jorts/ + +Or typing the below in a terminal, to move it to your Home folder: ```bash -cp ~/.var/app/io.github.elly_code.jorts/data ~/ +cp ~/.var/app/io.github.ellie_commons.jorts/data/io.github.ellie_commons.jorts/saved_data.json ~/ ``` -"saved_state.json" contains all notes in JSON format. The structure is quite simple, if not pretty. -The app reads from it only during startup (rest of the time it writes in) so you could quite easily swap it up to swap between sets of notes. +### If installed from elementary OS appcenter + +The app id is slightly different + +Enter the path: + +~/.var/app/io.github.elly_code.jorts/data/io.github.elly_code.jorts/ + +Or the command: + +```bash +cp ~/.var/app/io.github.elly_code.jorts/data/io.github.elly_code.jorts/saved_data.json ~/ +``` + + +### WINDOWS + +Paste in the explorer window: +%localappdata%\io.github.elly_code.jorts\ -ON WINDOWS: It's in: +### UNSUPPORTED PACKAGINGS -YourUserFolder \AppData\Local\io.github.elly_code.jorts +Check out in ~/.local/share -AppData is a hidden folder. Either you paste the above path in the path bar, from your user folder -Or you do a "Show hidden files" +It likely is there