shadow53 / hoard Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://hoard.rs
License: BSD 3-Clause "New" or "Revised" License
Home Page: https://hoard.rs
License: BSD 3-Clause "New" or "Revised" License
cargo publish
Allow an environment to require other environments to be true.
The simplest example is unix = ["linux", "freebsd", "macos", ...]
where each one is an environment matching the appropriate os.
A more useful example is personal_machine = ["my_laptop", "my_desktop", ...]
so that personal files don't accidentally get scattered around a work machine that I use programming dotfiles on.
Will definitely add some complexity to how environments are processed.
chrono
to time
causes deserialization errors with operation logs
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are currently rate-limited. Click on a checkbox below to force their creation now.
Warning
Renovate failed to look up the following dependencies: Failed to look up github-tags package devbotsxyz/xcode-select
.
Files affected: .github/workflows/check.yml
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
tracing
, tracing-subscriber
)Cargo.toml
async-stream 0.3
async-trait 0.1
clap 4.3
digest 0.10.7
futures 0.3
glob 0.3
hex 0.4.3
hostname 0.3
itertools 0.11.0
md-5 0.10.5
once_cell 1.15
open_cmd 0.1.0
petgraph 0.6
regex 1.8
serde >=1.0.184
serde_json 1.0
serde_yaml 0.9
sha2 0.10.7
similar 2.2
tap 1.0
tempfile 3.6
thiserror 1.0.40
time 0.3
tokio 1.28
tokio-stream 0.1
toml 0.8.2
tracing 0.1
tracing-subscriber 0.3
uuid 1.3
maplit 1.0
rand 0.8
serde_test 1.0
futures 0.3
tokio 1.28
serial_test 2.0.0
windows 0.51
registry 1.2
nix 0.27
pty_closure 0.1
Dockerfile
.github/workflows/audit.yml
actions/checkout v3
actions-rs/audit-check v1
.github/workflows/check.yml
actions/checkout v3
dorny/paths-filter v2
actions/checkout v3
fossa-contrib/fossa-action v2
actions/checkout v3
actions-rs/toolchain v1
actions-rs/install v0.1
actions-rs/install v0.1
actions-rs/cargo v1
actions/checkout v3
actions-rs/toolchain v1
actions-rs/install v0.1
actions-rs/install v0.1
actions-rs/cargo v1
actions/checkout v3
Swatinem/rust-cache v2
actions-rs/toolchain v1
actions-rs/cargo v1
actions/checkout v3
Swatinem/rust-cache v2
actions-rs/toolchain v1
actions/checkout v3
Swatinem/rust-cache v2
actions-rs/toolchain v1
actions-rs/toolchain v1
actions-rs/install v0.1
actions-rs/cargo v1
actions-rs/cargo v1
codecov/codecov-action v3
actions/checkout v3
Swatinem/rust-cache v2
actions-rs/toolchain v1
devbotsxyz/xcode-select v1
taiki-e/upload-rust-binary-action v1
.github/workflows/clippy.yml
actions/checkout v3
actions-rs/clippy-check v1
.github/workflows/publish-mdbook.yml
actions/checkout v3
actions-rs/install v0.1
nwtgck/actions-netlify v2
nwtgck/actions-netlify v2
.github/workflows/release.yml
actions/checkout v3
actions-rs/toolchain v1
knope-dev/action v2.0.0
Swatinem/rust-cache v2
Needed for #5 and blocked by #8.
The current basic design assumes either a single file or a single directory of which everything will be stored.
This needs a way to specify multiple files/folders for a target (easy) and a way to define where those files/folders can be found in different environments (harder).
As a simple example: Vim/Neovim on Windows/Linux.
$HOME/.vimrc
and ~/.vim
$HOME/_vimrc
and $HOME/.vim
$HOME/.config/nvim/init.vim
and $HOME/.config/nvim
$HOME/AppData/Local/nvim/init.vim
and $HOME/AppData/Local/nvim
Since one configuration can be shared between all four setups (with minor conditionals), I want to have one "hoarded" version of the configuration but correctly apply it based on environment.
The application is easy enough: copy from the hoard onto the filesystem. But how do we store these in the first place? Naively using the top-level name doesn't work if there are any conflicts. So some sort of unique id seems necessary.
How would we derive an id?
Perhaps how we set up configuration can make a difference. So what would configuration look like?
[environments]
[environments.winvim]
# ...
[environments.linvim]
# ...
[environments.winneo]
# ...
[environments.linneo]
# ...
[hoard]
[hoard.vim]
[[hoard.vim.files]]
id = "rcfile"
envs = {
winvim = "$HOME/_vimrc",
linneo = "$HOME/.config/nvim/init.vim",
# ...
}
... Maybe something else? Maybe using JSON instead?
list [hoard(s)]
: list all configured hoardslist pile(s) <hoard>
: list all piles in hoard
diff
: list all files that differ between the hoard and this machineedit
: opens the Hoard configuration file in the default editorFirst part of applying #5.
I'd like to make the following variables available for defining an environment.
Finally, I'd like to have a configuration item/command-line flag for overriding the detected environments, and another for determining whether to detect any when such a list is given.
If there is a large directory that I would like to backup that contains some folders within it that I'd like to ignore, it would be nice to be able to provide some sort of regex to ignore that pattern. The specific case I am referring to is that I am backing up my vimwiki
directory and it contains a .git
folder. On the first go-around it works perfectly fine; however, whenever I try to back it up a second time once something has changed, I get this error:
ERRORfailed to back up vimwiki: failed to copy /Users/lucasburns/vimwiki/music/.git/objects/0e/b565c87706e00
ec8efd3834f074db5175210e7 to /Users/lucasburns/.config/hoard/root/vimwiki/dir/music/.git/objects/0e/b565c87706
e00ec8efd3834f074db5175210e7: Permission denied (os error 13)
at src/main.rs:16
If there is something I can do already to fix this, I can try and see if that would work.
I do not think I have implemented this yet, and I definitely want to make sure there are tests to cover this. If I delete a configuration file (e.g. under a conf.d
directory), that deletion should propagate to the hoard on next backup.
I'm thinking something like using gitoxide to turn the saves folder into a git repository. Then we can do something like chezmoi init and download the git repo on new machines, make snapshots of the saves at different points in time, etc.
This includes listing hoards and piles within hoards
Should probably happen after #13.
Encryption using public/private key pairs. Probably PGP.
I'll need to do some investigation into the best ways to implement this in Rust.
I think these are related enough to put into an issue together.
The idea here is to detect differences between the hoard and the filesystem. hoard diff
then lists all of the files that differ and hoard status
lists just the hoards and whether the current machine was the last to touch them (hints at whether to back up or restore).
There may be an argument for showing a literal diff of textual files as well. This would require finding a library to find diffs and finding the best way to invoke a pager for scrolling (or just let the user pipe to it?)
config
is a reserved name for hoard/pile-level configuration. The error from trying to parse a pile named config
is unhelpful in communicating as much. I do not have the message in front of me, but it is along the lines of not being able to parse a Hoard
struct.
There should be a special case that, if parsing fails, checks for something named config
that doesn't look like a configuration.
Let's start with just attaching release builds to a tagged release. Things like package manager integrations can come later.
I believe both log
and tracing
have a way to indicate the context of a logged message. I already cannot easily tell what hoard/pile a message relates to, and the program is currently synchronous. Adding some context to the logs will make things much clearer.
This is partially needed for #75.
Checksum
enumThe logs created by the operation history checker will take up space over time. hoard
should provide a way to clean up old logs that are not useful to the checker.
This command could also be run automatically, but we should start with only manually.
It seems to be a common request, based on anecdotal evidence from announcing the last couple of releases on Reddit.
I initially chose TOML as the configuration file syntax because it is unambiguous, commonly used among and outside of Rust projects, and more readable than JSON.
From my understanding, YAML has ambiguity (different parsers can parse the same YAML differently) and can be frustrating to use with certain configuration structures, Still, I am willing to consider the feature if I feel it should add something.
For this issue, I am going to take my current configuration (which should be sufficiently long and complex to make the comparison) and translate it to YAML. If I feel there is a significant improvement in readability and/or writability, I may consider also supporting YAML config files.
I need to confirm this, but I was having some issues with files not being matched that should have been. Will need to update the relevant integration test too.
The README is getting rather long. Better to make a proper docs site for it.
Imported from Gitea
Both config.toml and games.toml are going to be in the system-specific configuration directory, which is different from where the Git repository will be stored. This means, though, that configurations will not be synced with the saves.
A good solution is to add a sync subcommand to config and game, and have their add and remove subcommands automatically call sync.
Just tried setting up a new system, got the following output:
INFO loading configuration...
at src/config/mod.rs:114
INFO loaded configuration.
at src/config/mod.rs:118
WARN path is neither file nor directory, skipping, path: /home/shadow53/.config/hoard/config.toml
at src/checkers/history/operation.rs:331
ERROR error while saving uuid to file, error: No such file or directory (os error 2)
at src/checkers/history/mod.rs:102
in running_checks
ERROR error while saving uuid to file, error: No such file or directory (os error 2)
at src/checkers/history/mod.rs:102
in running_checks
ERROR error while checking against recent remote operations: an I/O error occurred: No such file or directory (os error 2)
at src/main.rs:16
Some users may need step-by-step instructions for setting up their system(s) with Hoard,
Version: 0.4.0
Platform: x86_64-unknown-linux-gnu
I have a hoard named bash
that contains two piles:
# Bash rcfile
[hoards.bash.rcfile]
"linux" = "${HOME}/.bashrc"
# Bash aliases directory
[hoards.bash.aliases]
"linux" = "${HOME}/.bash_aliases.d/"
The file structure at the hoards root looks like this:
bash/:
drwxrwxr-x 3 dev dev 4.0K Dec 31 14:33 aliases/
drwxrwxr-x 2 dev dev 4.0K Dec 31 14:33 rcfile/
bash/aliases:
drwxrwxr-x 2 dev dev 4.0K Dec 31 01:05 .bash_aliases.d/
bash/aliases/.bash_aliases.d:
-rw-rw-r-- 1 dev dev 349 Dec 31 01:04 00-primary-aliases.sh
bash/rcfile:
-rw-r--r-- 1 dev dev 1.9K Dec 31 01:34 .bashrc
However, when I run hoard restore bash
I end up with the following directory structure under $HOME
:
❯ hoard restore bash
ignoring ``: invalid filter directive
WARN hoard::checkers::history::operation: path is neither file nor directory, skipping: path=/home/<user>/.bash_aliases.d
WARN hoard::checkers::history::operation: path is neither file nor directory, skipping: path=/home/<user>/.bashrc
restoring hoard: hoard=bash
❯ la ~/ | grep bash
drwxrwxr-x 3 dev dev 4.0K Jan 1 00:11 .bash_aliases.d/
drwxrwxr-x 2 dev dev 4.0K Jan 1 00:11 .bashrc/
❯ la ~/.bashrc
-rw-rw-r-- 1 dev dev 1.9K Jan 1 00:11 .bashrc
❯ la -R ~/.bash_aliases.d/
/home/dev/.bash_aliases.d/:
drwxrwxr-x 2 dev dev 4.0K Jan 1 00:11 .bash_aliases.d/
/home/dev/.bash_aliases.d/.bash_aliases.d:
-rw-rw-r-- 1 dev dev 349 Jan 1 00:11 00-primary-aliases.sh
In other words, hoard
creates an extra level of directories instead of placing my bashrc in ${HOME}/.bashrc
and my aliases in ${HOME}/.bash_aliases.d/
. Am I configuring hoard
incorrectly or is this a bug?
Imported from Gitea
Integration tests would be useful to have, to verify that things are working correctly during actual use.
The only thing I am not sure about is once Git support is added, since that adds extra complexity to every operation.
As part of this, I am also making sure all possible unit tests are implemented.
Current status:
I have filled in the remaining unit tests. This leaves the following items for integration testing:
Since integration tests are meant to test the public API of a program/library, and because the library is meant to only be consumed by the application (will make an issue for that), that leaves the following integration test(s):
As a side note, I'm not sure how to test the help
command.
Currently we hoard all or nothing. We should include a way to specify individual targets.
Include in release notes:
HOARD_LOG
env variable instead.The purpose of hoard
is to make it easy to synchronize random scattered files across machines, so it would be useful to have a way to detect the presence of unsynced changes.
hoards_root
that define the last time a hoard was backed up/a log of X recent backups$HOME/.cache/hoard
on *nix systemsrestore
backup
In the cases of warnings, the operation would abort until it is resolved. Users can force resolution by using a --force
flag.
If files are being restored for the first time, the record file would get copied to the cache location.
If done right, this should have an added benefit of allowing users to incorporate hoard
in shell rc files and scripts, where they will do nothing if there might be problems.
Command should open the configuration file in $EDITOR
or the system's default text editor.
System:
Darwin void.local 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64 i386 MacBookPro14,1 Darwin
I have gotten this error on a couple of the hoards
I have set:
$ hoard -l trace validate 【28s ~/.conf/hoard job】─╯
[2021-06-04T23:45:24Z INFO hoard::config] Loading configuration...
[2021-06-04T23:45:24Z ERROR hoard] error while building the configuration: failed to parse configuration file: data did not match any variant of untagged enum Hoard for key `hoards.gituip` at line 195 column 5
This was one of the sections it got hungup on:
[hoards.gitui]
[hoards.gitui.conf]
"macos" = "/Users/lucasburns/.config/gitui/key_config.ron"
[hoards.gituip.theme]
"macos" = "/Users/lucasburns/.config/gitui/theme.ron"
It also got hungup on another one where the hoard
was titled [hoard.bat]
with several sections underneath. On this one (bat
) I changed the name to batp
on the parent hoard
and changed the name on all of the children hoards
and it worked.
On the gitui
one, I tried the same thing but still got the same error. I took out the parent and left only one child, still got the error. Then i changed the name to something random like asdfasd
and it worked. I then changed it back to [hoard.gitui]
and then changed all the children back to gitui
and it works now. There was nothing else that I changed.
Error is thrown here:
[hoards.lazygit]
[hoards.lazygit.config]
"macos" = "/Users/lucasburns/.config/lazygit/config.yml"
[hoards.lazygit.state]
"macos" = "/Users/lucasburns/.config/lazygit/state.yml"
Change to this and still get error:
[hoards.lazygit.config]
"macos" = "/Users/lucasburns/.config/lazygit/config.yml"
Change to this and no error:
[hoards.lgasdf]
"macos" = "/Users/lucasburns/.config/lazygit/config.yml"
Add on test to make sure I can use .
, still no error here:
[hoards.lgasdf.test]
"macos" = "/Users/lucasburns/.config/lazygit/config.yml"
Change back to lazygit and it still works:
[hoards.lazygit.test]
"macos" = "/Users/lucasburns/.config/lazygit/config.yml"
Version: 0.4.0
Platform: x86_64-unknown-linux-gnu
> hoard --help
ignoring ``: invalid filter directive
hoard 0.4.0
The possible subcommands for `hoard`
USAGE:
hoard [FLAGS] [OPTIONS] [SUBCOMMAND]
FLAGS:
-f, --force
--help Prints help information
-V, --version Prints version information
OPTIONS:
-c, --config-file <config-file>
-h, --hoards-root <hoards-root>
SUBCOMMANDS:
backup Back up the given hoard(s)
cleanup Cleans up the operation logs for all known systems
help Prints this message or the help of the given subcommand(s)
list List configured hoards
restore Restore the files from the given hoard to the filesystem
validate Loads all configuration for validation. If the configuration loads and builds, this command succeeds
Notice the ignoring ``: invalid filter directive
message at the top (printed to stderr). This happens on every invocation of hoard
.
Running hoard --help
should only produce the help message.
hoard --help
SInce multiple hoards can be processed at once and each one may have multiple files, it may make sense to have multiple operations perform at once.
Not sure if this is best done with an async runtime like Tokio or making some background worker threads myself. A worker queue of some sort makes sense. I'll have to look into what is simplest to implement.
This serves as a meta-issue for both #12 and #21.
Track:
Usage:
hoard diff
command. (#12)hoard restore
(use last local checksum) (#21)hoard backup
(#21)TODO:
The new integration test in 26-prevent-file-footguns
(#26) is failing because a Windows-specific environment variable is not set on Linux. Delaying the processing of the path will fix this.
path_exists
conditions.${ENV_VARIABLE}
\${NOT_EXPANDED}
$NOT_EXPANDED
(error/warning?)${VAR_CONTAINS{_BRACE}
""
)
HOME
, XDG_*_HOME
, etc.)
directories
which depends on dirs
, and those can be used to detect values for XDG directories and such#40 just got fixed, which greatly improved calculated code coverage by including the Python-based integration tests. I'd like to further improve code coverage, with a goal of >90% coverage, 95% if possible.
Right now, no concern is given to when files are deleted.
hoard backup
, the copying process will fail with a warning
hoard restore
.hoard restore
.
This brings up some questions:
This question is related to #12 and should primarily be discussed there. As far as this issue is concerned, there is the possibility of knowing that a file was deleted from a pile (e.g. by a different machine), a separate possibility of knowing a file was deleted from the filesystem, and not knowing the previous state at all.
Depends on implementation details.
hoard
whether a file was intentionally deleted.This is similar to the above, but we no longer know the difference between a newly created file and a newly deleted one.
--force
flag to make the operation happen anyways.Also related to #12 and the possibility of having commands to check if a clean backup or restore can happen (i.e. no changes will be clobbered). I think the following applies:
There may be circumstances where merging configs may be difficult to figure out, but for right now it is simple enough and provides the least surprise to users.
There isn't much of anything specific to game saves for this program. Generalizing a bit, the feature set looks like this:
Definitions:
Integration tests provide most of the testing coverage now. If possible, I'd like to run the Python test scripts and generate coverage that can be uploaded to Codecov to more accurately reflect testing coverage.
There is a little bit of configuration support for this already, but no actual support.
Essentially, backed up files will get encrypted using a given password, and restored files will be decrypted by the same.
There will be two sources of password: a raw password password = ""
and a password command to retrieve it from somewhere else.
I'll need to do research into the best encryption to use for both speed and security. AES, probably.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.