implement locate and updatedb
closes #60
Given that locate has largely been replaced by (m|p)locate, I was unable to find a version of locate packaged for my system (latest Arch Linux), and the packaged version of updatedb does not use the LOCATE02 db format. When running updatedb from source, I encountered errors that were not immediately fixable. As such, this implementation is largely untested, but it's better to have something here to be improved upon.
cool, thanks :) a bunch of tasks are failing
add please add tests :)
Codecov Report
:x: Patch coverage is 91.99372% with 51 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 87.80%. Comparing base (a607612) to head (1acd3f8).
:warning: Report is 58 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/locate/mod.rs | 90.04% | 23 Missing and 19 partials :warning: |
| src/updatedb/mod.rs | 95.65% | 6 Missing and 3 partials :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #536 +/- ##
==========================================
+ Coverage 87.69% 87.80% +0.10%
==========================================
Files 31 35 +4
Lines 6893 6937 +44
Branches 324 355 +31
==========================================
+ Hits 6045 6091 +46
+ Misses 617 597 -20
- Partials 231 249 +18
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
A couple notes:
- User flags are ignored for updatedb. GNU/BSD/Apple implementations all use a shell script, so they have direct access to su. I'm not sure if there's a better solution from rust, but I left it alone for now.
- Performance is pretty significantly worse than GNU for updatedb. It might be a problem with find, since updatedb delegates most of the work to it. Locate is about on par with GNU for the one test that I did. I'd love another set of eyes to look for improvements.
- I'll fix coverage issues tomorrow.
- Looks like Release / plan is failing due to the Ubuntu 20.04 test runner no longer being available. Is that as simple a fix as updating it to 22.04 or later?
Is there a reason for the kill switch which blocks operation on Windows?
Proper locate tool may be really interesting in the Windows world, where one would not have to install mingw or cygwin environments.
@Code7R The current implementation of locate relies on the UNIX-only OsStr::from_bytes. It might be possible to work around this on Windows with OsString::from_wide, but that at least requires a new allocation, and I'm not well-versed enough with Windows encodings to confidently identify how to properly convert from the &[u8] (read in from the db) to &[u16] (required by from_wide). As for updatedb, There's nothing explicitly preventing it from running on Windows, but I can't say with certainty that it doesn't make any UNIX-only assumptions.
@sylvestre any updates here?