Add support for isolated files.

I call isolated those files that are just lying there
withot a corresponding .metadata file.
This commit is contained in:
King_DuckZ 2021-03-26 20:53:20 +01:00
parent 2ce7f4cfaf
commit 5f41af76b4

View file

@ -41,6 +41,7 @@ struct NotebookInfo {
std::uint64_t version = 0;
std::uintmax_t total_size = 0;
bool deleted = false;
bool isolated = true;
};
struct Node {
@ -106,6 +107,7 @@ NotebookMapType build_notebook_infos (
curr_info.type = json_doc["type"];
curr_info.version = json_doc["version"];
curr_info.visible_name = json_doc["visibleName"];
curr_info.isolated = false;
}
else if (fs::is_directory(entry)) {
for (const auto& subentry : fs::recursive_directory_iterator(entry)) {
@ -167,9 +169,12 @@ std::vector<Node> to_tree (const NotebookMapType& nbs) {
return roots;
}
void print_tree (const Node& tree, std::string_view desc={}, std::string indent={}) {
std::cout << indent << desc << " (\"" << tree.name << "\")";
if (tree.info and tree.info->deleted)
if (tree.info && tree.info->isolated)
std::cout << " ISOLATED";
else if (tree.info and tree.info->deleted)
std::cout << " DELETED";
std::cout << '\n';
@ -200,7 +205,7 @@ std::vector<const NotebookInfo*> to_flat_notebook_list (const Node& tree) {
}
std::vector<const NotebookInfo*> make_dele_list (const Node& tree) {
if (tree.info and tree.info->deleted)
if (tree.info and (tree.info->deleted or tree.info->isolated))
return to_flat_notebook_list(tree);
std::vector<const NotebookInfo*> retval;