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

Track file modifications to prevent footguns #26

Closed
13 tasks done
Shadow53 opened this issue Jun 21, 2021 · 0 comments · Fixed by #29
Closed
13 tasks done

Track file modifications to prevent footguns #26

Shadow53 opened this issue Jun 21, 2021 · 0 comments · Fixed by #29
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Shadow53
Copy link
Owner

Shadow53 commented Jun 21, 2021

This serves as a meta-issue for both #12 and #21.

Track:

  1. Files updated by remote system
  2. Files updated by local system
  3. Local files that differ from hoard
  4. Paths previously used for each pile
  5. File checksums?

Usage:

TODO:

  • Implement previous-path file and related check (see Handling deleted files #21 for possible format)
  • Generate per-device UUIDs for log files
  • Implement log file format that tracks files that have changed
    • may have to use checksums to avoid marking unchanged files as changed
    • Also track file creation/deletion
    • Include timestamp
  • Implement parsing and combining log files from multiple devices to determine where a file was last modified
  • Implement checks based on where a file was last modified
@Shadow53 Shadow53 added the enhancement New feature or request label Jun 21, 2021
@Shadow53 Shadow53 added this to the 0.3.0 milestone Jun 21, 2021
@Shadow53 Shadow53 self-assigned this Jun 21, 2021
This was referenced Jun 21, 2021
Shadow53 added a commit that referenced this issue Aug 30, 2021
* feat: create unique UUID for each system

* test: fix tests

* feat: impl last paths checks and force flag

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.

* test: add last_path tests

* refactor: create and use Checker trait for LastPaths

* feat: add Operation Checker

* fix: fix clippy lints

* ci: add proper integration test for last_paths

* style: run cargo fmt

* ci: try to fix running python script in CI

* fix(ci): fix imports in test.py

* fix(test.py): args -> argv

* ci: do not error if files don't exist yet

* ci(test.py): create parent directories as needed

* ci(test.py): parent is attribute, not method

* ci(test.py): don't shadow variables

* ci(test.py): args might be a list

* ci: attempt to set home folder for integration tests

* ci: fix hardcoded home directories

* ci: use single instead of double quotes

* fix: show what environment variable failed to expand

* ci: see if setting shell fixes setting env

* ci: fix env in test.py

* ci(test.py): use correct env values

* fix: process paths after getting matches

Resolves #28

* ci(config.toml): add unix to exclusivity list

* feat: improve hoard env processing

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.

* style: run cargo fmt

* ci: trace integration tests

* fix: improve debugging messages in envtrie

* fix(envtrie): set score correctly on created nodes

* chore: run cargo update

* fix: change how weighted map is calculated

Previously, a topological sort of a DAG gave every environment a unique
weight. When setting scores on nodes was fixed, this broke an
integration test that ensures an error occurs in ambiguous situations.

Given:

```
exclusivity = [
    ["foo", "bar"],
    ["baz", "bar"]
]

[hoards.example]
    "foo" = "/some/path"
    "baz" = "/other/path"
```

Should foo or baz be chosen? The answer is neither, because they are
equal precedence over bar. The DAG method gave them unique weights,
though, so no error occurred. This is fixed by simplifying how weights
are determined: just use the reverse-order index in the exclusivity
list.

In this case, inserting a mutually exclusive item between foo and bar
will cause foo to be chosen over baz. This is fine though, since we
interpret this to mean that foo is more specific than baz.

* ci: remove trace for integration tests

* ci: more explicitly make sure env is set every time

* ci: fix config file, revert setting env explicitly

* ci(test.py): fix calls to running hoard

* ci: skip jobs when things haven't changed

* ci: set revision on paths-filter

* ci(test.py): list expected files in directories

* ci(test.py): direntries must be strings

* ci(test.py): undo overzealous find/replace

* ci(test.py): reposition the force flag

* ci(test.py): make kwargs explicit

* fix(config): localize use of LocalPaths

* ci(test.py): insert missing command

* ci(test.py): print debugging information on error

* ci(test.py): convert Path to str before subprocess.run

* ci(test.py): build Path instead of using strings

* ci(test.py): fix script errors

* ci: use action to install latest Python

* ci: add branch to python-install action

* ci: add C drive to config.toml

* style: run cargo fmt

* test: add operation checker integration test

* fix: fix operations checker, add more logging

* fix: make clippy and rustfmt happy

* ci: add operations integration check to CI

* refactor: minor cleanup

* refactor: use only HashMaps, not also BTreeMaps

* refactor: actually impl Checker and use the impls

* style: run cargo fmt

* fix: last_paths tests

* ci: install tree on macos

* test: no need to truncate; move around whitespace
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant