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

Give more guarantees on the ordering of the tarball entries #20

Open
andreabedini opened this issue Oct 27, 2022 · 1 comment
Open

Give more guarantees on the ordering of the tarball entries #20

andreabedini opened this issue Oct 27, 2022 · 1 comment

Comments

@andreabedini
Copy link
Member

So far I am sorting by timestamp but I should sort secondarily on package id too.

@andreabedini
Copy link
Member Author

Of course we don't want to break everybody's index, so we need to understand what's the current order and guarantee it stays the same. Looking at CHaP it seems currently we have cabal files ordered by package-id (or I should say filepath) followed by all package.json files (again by package-id/filepath).

-rw-r--r-- foliage/foliage 20985 2022-10-21 00:00:00 plutus-core/1.1.0.0/plutus-core.cabal
-rw-r--r-- foliage/foliage  4489 2022-10-21 00:00:00 plutus-ledger-api/1.1.0.0/plutus-ledger-api.cabal
-rw-r--r-- foliage/foliage  4112 2022-10-21 00:00:00 plutus-tx/1.1.0.0/plutus-tx.cabal
-rw-r--r-- foliage/foliage  4642 2022-10-21 00:00:00 plutus-tx-plugin/1.1.0.0/plutus-tx-plugin.cabal
-rw-r--r-- foliage/foliage  2395 2022-10-21 00:00:00 prettyprinter-configurable/1.1.0.0/prettyprinter-configurable.cabal
-rw-r--r-- foliage/foliage  1714 2022-10-21 00:00:00 word-array/1.1.0.0/word-array.cabal
-rw-r--r-- foliage/foliage  1391 2022-10-21 00:00:00 plutus-core/1.1.0.0/package.json
-rw-r--r-- foliage/foliage  1396 2022-10-21 00:00:00 plutus-ledger-api/1.1.0.0/package.json
-rw-r--r-- foliage/foliage  1388 2022-10-21 00:00:00 plutus-tx/1.1.0.0/package.json
-rw-r--r-- foliage/foliage  1395 2022-10-21 00:00:00 plutus-tx-plugin/1.1.0.0/package.json
-rw-r--r-- foliage/foliage  1405 2022-10-21 00:00:00 prettyprinter-configurable/1.1.0.0/package.json
-rw-r--r-- foliage/foliage  1388 2022-10-21 00:00:00 word-array/1.1.0.0/package.json

We need to guarantee that this order is stable. At the moment this ordering is an incidental consequence of doing

  packageVersions <- getDirectoryFiles inputDir ["*/*/meta.toml"] >>= traverse something1
  cabalEntries <- foldMap something2 packageVersions
  metadataEntries <- forP packageVersions something3
  let tarContents = Tar.write $ sortOn Tar.entryTime (cabalEntries ++ metadataEntries)

That forP is concering, there could be multiple packages added with the same timestamp and their relative order might not be guaranteed. getDirectoryFiles seems to do some sorting in its implementation but I am not sure we can call this a guarantee.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant