Skip to content

Commit

Permalink
Add versioning to the storage system
Browse files Browse the repository at this point in the history
  • Loading branch information
Slackadays committed Oct 11, 2024
1 parent 361bb6e commit dcdd315
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/cb/src/clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned long> Clipboard::generatedEntryIndex() {
Expand Down
8 changes: 6 additions & 2 deletions src/cb/src/clipboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;

Expand Down Expand Up @@ -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; }
Expand Down

0 comments on commit dcdd315

Please sign in to comment.