mcorbin / meuse

A private Cargo crate registry, for Rust

Home Page:https://meuse.mcorbin.fr/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

database and repo out of sync sometimes

ian-p-cooke opened this issue · comments

this was a mistake on my part but thought I should mention it as other situations might arise that are similar:

when I initially created the repo (metadata.path) I just created an empty directory and forgot about it. when I attempted to publish a crate the git part failed because it wasn't actually a repo. I fixed that and tried to publish again but meuse complained that the package version already existed. Sure enough it had written the database entries. I deleted those rows and was able to publish again.

it seems to me like the database writing and the git updating should be atomic.

Yes, I already identified this issue.

The registry has its state in 3 places:

  • The database.
  • The Git repository where the crates metadata are stored.
  • The drectory where the crates files are stored.

Meuse should indeed try to sync everything. I will add better error handling in the future, and I will also probably run a thread which will periodically list crates, and report crates with state issues.

personally, I think I'd rather have a separate 'integrity check' cli that I could schedule as needed with cron. no need to burn a thread for something that really shouldn't happen, IMO.

I added a new call (GET /api/v1/meuse/check) which detects these issues.

Here is an example output:

[
  {
    "crate": "crate1",
    "errors": [
      "metadata does not exist for version 1.1.0",
      "metadata does not exist for version 1.1.4",
      "metadata does not exist for version 1.1.5",
      "crate binary file does not exist for version 1.1.0",
      "crate binary file does not exist for version 1.1.4",
      "crate binary file does not exist for version 1.1.5"
    ]
  },
  {
    "crate": "crate2",
    "errors": [
      "metadata does not exist for version 1.3.0",
      "crate binary file does not exist for version 1.3.0"
    ]
  },
  {
    "crate": "crate3",
    "errors": [
      "metadata does not exist for version 1.4.0",
      "crate binary file does not exist for version 1.4.0"
    ]
  },
  {
    "crate": "foo",
    "errors": [
      "metadata does not exist for version 1.10.2",
      "metadata does not exist for version 1.10.3",
      "crate binary file does not exist for version 1.10.2",
      "crate binary file does not exist for version 1.10.3"
    ]
  }
]

I will tag a new release of the project in 1 or 2 weeks and update the documentation website (I added a lot of new calls since the last release).