moriturus / ktra

Your Little Cargo Registry

Home Page:https://book.ktra.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What are the recovery expectations of ktra

garyanaplan opened this issue · comments

First: Thanks for working on this. I've been experimenting with it the last couple of days and it's great.

I don't know if this is an issue or simply expected behavior, so I thought I'd ask.

If I start ktra and then publish a few crates, my git repo is updated correctly and the various queries about which crates are available etc all work as expected.

Then: I delete my database (I'm using sled), index and my crates directory. (i.e. all contents created and managed by ktra).
Now, when I start ktra, it happily updates my index and seems to "do the right thing" in terms of populating that with the name of my crates from my git repo. I create a new user and get a token and then when I use that to ask ktra what crates are available I get an empty list.

I know deleting my database, etc... is a silly thing to do, but I sort of feel like it should be possible to recreate (most of) the contents of the ktra data based on the information that is stored in the git repo. So, that's my question really. Should it be possible?

Hi @garyanaplan, thank you for using Ktra.

To come to the point, and unfortunately, it is not possible to restore deleted database and crates data from the index git repository.
A metadata sent by cargo when you hit cargo publish command is similar to the index data but not the same. The metadata can map onto the index data but not vice versa.
Additionally, the checksum of crate binary data is calculated when it is published so if you remove crates directory you cannot retrieve it too.

Feel free to write a comment if you have more questions 👍.

That's totally fine. I wanted to get a better idea of how things worked and you've made that very clear. Thank you!

commented

@moriturus I have a follow up question.

What's the purpose of git index if it contains only a subset of data published to the database? It sounds redundant as it'd seem that database+crates tars (archives) should be enough but I'm surely missing something?

The git index is how cargo does the dependency resolution/interacts with a registry, see https://doc.rust-lang.org/cargo/reference/registries.html#index-format