| 3090 | } |
| 3091 | |
| 3092 | BookmarkManager::KMLDataCollectionPtr BookmarkManager::PrepareToSaveBookmarks( |
| 3093 | kml::GroupIdCollection const & groupIdCollection) |
| 3094 | { |
| 3095 | CHECK_THREAD_CHECKER(m_threadChecker, ()); |
| 3096 | |
| 3097 | std::string const fileDir = GetBookmarksDirectory(); |
| 3098 | |
| 3099 | if (!Platform::IsFileExistsByFullPath(fileDir) && !Platform::MkDirChecked(fileDir)) |
| 3100 | return nullptr; |
| 3101 | |
| 3102 | auto collection = std::make_shared<KMLDataCollection>(); |
| 3103 | for (auto const groupId : groupIdCollection) |
| 3104 | { |
| 3105 | auto * group = GetBmCategory(groupId); |
| 3106 | |
| 3107 | // Get valid file name from category name |
| 3108 | std::string file = group->GetFileName(); |
| 3109 | if (file.empty()) |
| 3110 | { |
| 3111 | std::string name = RemoveInvalidSymbols(group->GetName()); |
| 3112 | if (name.empty()) |
| 3113 | name = kDefaultBookmarksFileName; |
| 3114 | |
| 3115 | file = GenerateUniqueFileName(fileDir, std::move(name), kKmlExtension); |
| 3116 | group->SetFileName(file); |
| 3117 | // Only append to the custom order if it has been activated (non-empty). |
| 3118 | if (!m_metadata.m_categoryOrder.empty()) |
| 3119 | { |
| 3120 | auto const fileBasename = base::FileNameFromFullPath(file); |
| 3121 | if (std::find(m_metadata.m_categoryOrder.begin(), m_metadata.m_categoryOrder.end(), fileBasename) == m_metadata.m_categoryOrder.end()) |
| 3122 | m_metadata.m_categoryOrder.push_back(fileBasename); |
| 3123 | } |
| 3124 | } |
| 3125 | |
| 3126 | collection->emplace_back(std::move(file), CollectBmGroupKMLData(group)); |
| 3127 | } |
| 3128 | return collection; |
| 3129 | } |
| 3130 | |
| 3131 | void BookmarkManager::SaveBookmarks(kml::GroupIdCollection const & groupIdCollection) |
| 3132 | { |
nothing calls this directly
no test coverage detected