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

Bump minor version and add new api to get if archive has alias. #847

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

mgautierfr
Copy link
Collaborator

Fix #844

Copy link

codecov bot commented Dec 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (abf7c11) 57.59% compared to head (447b96d) 57.60%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #847   +/-   ##
=======================================
  Coverage   57.59%   57.60%           
=======================================
  Files          99       99           
  Lines        4589     4590    +1     
  Branches     1920     1922    +2     
=======================================
+ Hits         2643     2644    +1     
  Misses        677      677           
  Partials     1269     1269           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/fileimpl.cpp Outdated
@@ -599,6 +599,10 @@ class Grouping
return zimReader->size();
}

bool FileImpl::mayHaveAliasEntry() const {
return header.getMinorVersion() >= 2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ZIM format have version 5.2? Then this check is incorrect.
Besides it is not future-proof and will need to be updated when the major version is bumped.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, the same problem is present with the detection of whether the ZIM archive uses the new namespace scheme:

const_cast<bool&>(m_newNamespaceScheme) = header.getMinorVersion() >= 1;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ZIM format have version 5.2?

No. Major version 6 is same as 5 but with extended cluster (blob bigger than for 4GB).
It has been use in parallel for a time then only 6.
Minor version was 0, then 1 for new namespace scheme (both with major 5 or 6) and now 2 (with 6 only, but it would be valid even with major 5)

Comment on lines 470 to 477
* This method is just a hint.
* If true, its means that zim archive has been created with a implementation
* allowing alias creation.
* If false, it means that zim archive has been created before we
* formalize alias concept. But it would be still valid (from the spec)
* to have alias in the archive.
*/
bool mayHaveAliasEntry() const;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The potential benefits of having such a method are not clear. If the implementation supporting alias creation records (e.g. in metadata) the information about actual presence of aliases in a ZIM archive (and that is made part of the ZIM spec) then this method could be replaced with a tri-value (true, false, unknown) hasAliases() which is more meaningful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The potential benefits of having such a method are not clear.

Just a hint which can be used at reader level (for example) to change behaviour. I believe we will use this just to perform checks in a differentiated manner based of ZIM version.

If the implementation supporting alias creation records (e.g. in metadata) the information about actual presence of aliases in a ZIM archive (and that is made part of the ZIM spec) then this method could be replaced with a tri-value (true, false, unknown) hasAliases() which is more meaningful.

There is no real quick way to know AFAIK that we have aliases and therefore don't think this is really doable to do that efficiently. The "may" versuin seems good enough.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to add that if this new method just generate to much lack of consensus. On my side, this is OK to remove it (which means implicitly that for know we always consider a ZIM having - potentially - aliases).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the implementation supporting alias creation records (e.g. in metadata) the information about actual presence of aliases in a ZIM archive (and that is made part of the ZIM spec) then this method could be replaced with a tri-value (true, false, unknown) hasAliases() which is more meaningful.

There is no real quick way to know AFAIK that we have aliases and therefore don't think this is really doable to do that efficiently. The "may" versuin seems good enough.

With the new libzim aliases are created via a public API (zim::writer::Creator::addAlias()) and therefore Creator can keep track of whether any aliases have been added to the ZIM archive and save that information in some standardized way. Implementing it should be trivial. Defining the enhancement of the ZIM spec may be harder than implementing it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@veloman-yunkan Sorry I have merged a bit quickly... I agree with your last comment, but the core of the discussion as been already run at #833 (comment)?! I believe it is good like this. If it is proven we need more, we will do more.

@mgautierfr
Copy link
Collaborator Author

I've removed the new API. So now the PR is just changing the minor version.

@kelson42 kelson42 merged commit 9f1cbab into main Dec 15, 2023
30 checks passed
@kelson42 kelson42 deleted the bump_minor_version branch December 15, 2023 07:42
@kelson42 kelson42 added this to the 9.1.0 milestone Dec 16, 2023
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

Successfully merging this pull request may close these issues.

Bump minor version of zimfile format
3 participants