From dcdd31511c67789f92c5b590cc05317982ab233a Mon Sep 17 00:00:00 2001 From: Slackadays Date: Fri, 11 Oct 2024 16:39:43 -0400 Subject: [PATCH] Add versioning to the storage system --- src/cb/src/clipboard.cpp | 3 +++ src/cb/src/clipboard.hpp | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cb/src/clipboard.cpp b/src/cb/src/clipboard.cpp index 48529f692..735c54ee5 100644 --- a/src/cb/src/clipboard.cpp +++ b/src/cb/src/clipboard.cpp @@ -47,9 +47,12 @@ Clipboard::Clipboard(const std::string& clipboard_name, const unsigned long& cli metadata.notes = metadata / constants.notes_name; metadata.originals = metadata / constants.original_files_name; metadata.script = metadata / constants.script_name; + metadata.version = metadata / constants.storage_protocol_version_name; fs::create_directories(data); fs::create_directories(metadata); + + writeToFile(metadata.version, std::string(constants.storage_protocol_version)); } std::deque Clipboard::generatedEntryIndex() { diff --git a/src/cb/src/clipboard.hpp b/src/cb/src/clipboard.hpp index 611c60b18..d57eb11b1 100644 --- a/src/cb/src/clipboard.hpp +++ b/src/cb/src/clipboard.hpp @@ -78,8 +78,6 @@ struct Constants { std::string_view clipboard_version = CLIPBOARD_VERSION; std::string_view clipboard_commit = GIT_COMMIT_HASH; std::string_view data_file_name = "rawdata.clipboard"; - std::string_view default_clipboard_name = "0"; - unsigned long default_clipboard_entry = 0; std::string_view persistent_directory_name = ".local/state/clipboard"; std::string_view original_files_name = "originals"; std::string_view notes_name = "notes"; @@ -92,6 +90,11 @@ struct Constants { std::string_view metadata_directory = "metadata"; std::string_view import_export_directory = "Exported_Clipboards"; std::string_view temporary_directory_name = "Clipboard"; + std::string_view default_clipboard_name = "0"; + std::string_view storage_protocol_version_name = "version"; + + unsigned long default_clipboard_entry = 0; + std::string_view storage_protocol_version = "1"; }; constexpr Constants constants; @@ -289,6 +292,7 @@ class Clipboard { fs::path notes; fs::path originals; fs::path script; + fs::path version; operator fs::path() { return root; } operator fs::path() const { return root; } auto operator=(const auto& other) { return root = other; }