Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get_lots_from_dir in rootly path case #17

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/lotman_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1818,9 +1818,11 @@
return std::make_pair(rp.first, "");
}

std::pair<std::vector<std::string>, std::string> lotman::Lot::get_lots_from_dir(std::string dir, const bool recursive) {

Check warning on line 1821 in src/lotman_internal.cpp

View workflow job for this annotation

GitHub Actions / Run linters

[lint] reported by reviewdog 🐶 Raw Output: src/lotman_internal.cpp:1821:-std::pair<std::vector<std::string>, std::string> lotman::Lot::get_lots_from_dir(std::string dir, const bool recursive) { src/lotman_internal.cpp:1822:- if (dir.back() == '/') { // Remove the character src/lotman_internal.cpp:1823:- if (dir.length() > 1) { src/lotman_internal.cpp:1824:- dir.pop_back(); src/lotman_internal.cpp:1825:- } src/lotman_internal.cpp:1826:- } src/lotman_internal.cpp:1827:- src/lotman_internal.cpp:1828:- std::string lots_from_dir_query = "SELECT lot_name FROM paths " src/lotman_internal.cpp:1829:- "WHERE " src/lotman_internal.cpp:1830:- "(path = ? OR ? LIKE path || '/%') " // The incoming file path is either the stored file path or a subdirectory of it src/lotman_internal.cpp:1831:- "AND " src/lotman_internal.cpp:1832:- "(recursive OR path = ?) " // If the stored file path is not recursive, we only match the exact file path src/lotman_internal.cpp:1833:- "ORDER BY LENGTH(path) DESC LIMIT 1;"; // We prefer longer matches over shorter ones src/lotman_internal.cpp:1834:- std::map<std::string, std::vector<int>> dir_str_map{{dir, {1,2,3}}}; src/lotman_internal.cpp:1835:- auto rp = lotman::Checks::SQL_get_matches(lots_from_dir_query, dir_str_map); src/lotman_internal.cpp:1836:- if (!rp.second.empty()) { src/lotman_internal.cpp:1837:- std::string int_err = rp.second; src/lotman_internal.cpp:1838:- std::string ext_err = "Failure on call to SQL_get_matches: "; src/lotman_internal.cpp:1839:- return std::make_pair(std::vector<std::string>(), ext_err + int_err); src/lotman_internal.cpp:1840:- } src/lotman_internal.cpp:2154:+std::pair<std::vector<std::string>, std::string> src/lotman_internal.cpp:2155:+lotman::Lot::get_lots_from_dir(std::string dir, const bool recursive) { src/lotman_internal.cpp:2156:+ if (dir.back() == '/') { // Remove the character src/lotman_internal.cpp:2157:+ if (dir.length() > 1) { src/lotman_internal.cpp:2158:+ dir.pop_back(); src/lotman_internal.cpp:2159:+ } src/lotman_internal.cpp:2160:+ } src/lotman_internal.cpp:2161:+ src/lotman_internal.cpp:2162:+ std::string lots_from_dir_query = src/lotman_internal.cpp:2163:+ "SELECT lot_name FROM paths " src/lotman_internal.cpp:2164:+ "WHERE " src/lotman_internal.cpp:2165:+ "(path = ? OR ? LIKE path || '/%') " // The incoming file path is either src/lotman_internal.cpp:2166:+ // the stored file path or a src/lotman_internal.cpp:2167:+ // subdirectory of it src/lotman_internal.cpp:2168:+ "AND " src/lotman_internal.cpp:2169:+ "(recursive OR path = ?) " // If the stored file path is not recursive, we src/lotman_internal.cpp:2170:+ // only match the exact file path src/lotman_internal.cpp:2171:+ "ORDER BY LENGTH(path) DESC LIMIT 1;"; // We prefer longer matches over src/lotman_internal.cpp:2172:+ // shorter ones src/lotman_internal.cpp:2173:+ std::map<std::string, std::vector<int>> dir_str_map{{dir, {1, 2, 3}}}; src/lotman_internal.cpp:2174:+ auto rp = lotman::Checks::SQL_get_matches(lots_from_dir_query, dir_str_map); src/lotman_internal.cpp:2175:+ if (!rp.second.empty()) { src/lotman_internal.cpp:2176:+ std::string int_err = rp.second; src/lotman_internal.cpp:2177:+ std::string ext_err = "Failure on call to SQL_get_matches: "; src/lotman_internal.cpp:2178:+ return std::make_pair(std::vector<std::string>(), ext_err + int_err); src/lotman_internal.cpp:2179:+ } src/lotman_internal.cpp:2180:+ src/lotman_internal.cpp:2181:+ std::vector<std::string> matching_lots_vec; src/lotman_internal.cpp:2182:+ if (rp.first.empty()) { // No associated lots were found, indicating the src/lotman_internal.cpp:21
if (dir.back() == '/') { // Remove the character
dir.pop_back();
if (dir.length() > 1) {
dir.pop_back();
}
}

std::string lots_from_dir_query = "SELECT lot_name FROM paths "
Expand Down
Loading