From 49f2c3d4cb055c50c0eeef2d1d66a5034604b329 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 26 Mar 2021 21:08:54 +0100 Subject: [PATCH] Clean up --- main.cpp | 70 +------------------------------------------------------- 1 file changed, 1 insertion(+), 69 deletions(-) diff --git a/main.cpp b/main.cpp index 04f7dd0..77c8b46 100644 --- a/main.cpp +++ b/main.cpp @@ -63,26 +63,6 @@ struct Node { typedef std::unordered_map NotebookMapType; -std::ostream& operator<< (std::ostream& str, const NotebookMapType::value_type& v) { - auto& key = v.first; - auto& val = v.second; - str << key << " (\"" << val.visible_name << "\", " << val.type << - "): deleted=" << std::boolalpha << val.deleted << - ", parent=\"" << val.parent << - "\", version=" << val.version << - ", files="; - - std::string_view sep(""); - for (const auto& f : val.files) { - str << sep << f; - sep = ";"; - } - - str << ", size=" << std::setprecision(2) << - static_cast(val.total_size) / (1024.0 * 1024.0) << "MiB"; - return str; -} - template std::vector& operator+= (std::vector& dst, const std::vector& src) { dst.insert(dst.end(), src.begin(), src.end()); @@ -219,61 +199,13 @@ int main() { using std::string_view; auto notebooks = build_notebook_infos(BASE_PATH); - - //naive linear delete - //std::uintmax_t total = 0; - //std::uintmax_t freed = 0; - //std::set dele_list; - //for (auto& nb : notebooks) { - // if (nb.second.deleted) { - // dele_list.insert(nb.first); - // for (const auto& file : nb.second.files) { - // std::cout << BASE_PATH << file << '\n'; - // } - // freed += nb.second.total_size; - // } - // total += nb.second.total_size; - //} - - //for (auto& nb : notebooks) { - // if (dele_list.count(nb.second.parent) and not nb.second.deleted) { - // std::cerr << "Warning: " << nb.second.parent << " deleted but it's the parent of " << nb.first << "!\n"; - // } - //} - // - //std::cout << "Found " << notebooks.size() << " notebooks\n"; - //std::cout << "Total size " << std::setprecision(2) << - // static_cast(total) / (1024.0 * 1024.0 * 1024.0) << "GiB\n"; - //std::cout << "Would delete " << dele_list.size() << " notebooks\n"; - //std::cout << "Would free " << std::setprecision(2) << - // static_cast(freed) / (1024.0 * 1024.0 * 1024.0) << "GiB\n"; - std::vector roots = to_tree(notebooks); - //std::cout << "Found " << notebooks.size() << " notebooks\n"; - //std::cout << "Collection has " << roots.size() << " roots\n"; - //std::cout << " ---------\n"; - //for (const auto& root : roots) { - // std::cout << "\tTree \"" << root.name << "\" has " << root.children.size() << " nodes\n\n"; - //} - - //std::uintmax_t total_mem1 = 0; std::vector dele_list; - for (const auto& root : roots) { - //std::string_view desc; - //if (root.name == "trash") - // desc = "rubbish bin"; - //else if (root.name == "") - // desc = "root"; - //print_tree(root, desc); - //total_mem1 += recursive_size(root); + for (const auto& root : roots) { dele_list += make_dele_list(root); } - //std::cout << "Total size 1: " << total_mem1 << " bytes\n"; - //const std::uintmax_t total_mem2 = std::accumulate(notebooks.cbegin(), notebooks.cend(), std::uintmax_t{}, [](std::uintmax_t a, const auto& b) {return a + b.second.total_size;}); - //std::cout << "Total size 2: " << total_mem2 << " bytes\n"; - for (const NotebookInfo* nb : dele_list) { for (const auto& f : nb->files) { std::cout << "/home/root/.local/share/remarkable/xochitl/" << f << '\n';