-
Notifications
You must be signed in to change notification settings - Fork 2
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
#26: Prevent file footguns #29
Conversation
This commit includes the relevant `LastPaths` types, implementing checks for changed paths. Also includes a `--force` flag for allowing the operation to continue without the check.
Rather than creating a sum of scores, which can easily have collisions between different sets of scores, keep track of every score in the tree path. A path is considered a better match using the following algorithm: 1. The path with more nodes is better. 2. If paths are equal length, the one with more higher numbers is better. - Of `A: [7, 3, 2, 1]` and `B: [5, 4, 3, 2]`, `B` is the better match because it generally has higher scores than `A`. 3. If the paths have equal numbers of higher scores, abort with error.
Codecov Report
@@ Coverage Diff @@
## main #29 +/- ##
==========================================
- Coverage 60.84% 56.83% -4.01%
==========================================
Files 16 17 +1
Lines 1637 1990 +353
Branches 395 509 +114
==========================================
+ Hits 996 1131 +135
- Misses 355 517 +162
- Partials 286 342 +56
Continue to review full report at Codecov.
|
Tests pass, codecov does not consider the Python script for coverage (which provides more coverage than unit tests could, imo), and I am content with the state of the codebase at this point. |
Resolves #26 and #28.
Implements two checks:
Check 1: Last Paths
This check validates that the paths being used in the current operation are the same as the most recent operation on that hoard. If the paths are different, this may constitute an unintentional environment change. Users can double-check that the paths being used are the intended ones, and then use the
--force
flag to make the operation go through.Check 2: Remote Operations
This check uses (hopefully synchronized) records from other systems to determine if the most recent update of a file happened locally or on a remote system. If it happened on a remote system, any backup operation is cancelled to prevent accidentally overwriting remote changes. Again, this check can be disabled using the
--force
flag.