Skip to content

Commit

Permalink
Bump minor version and add new api to get if archive has alias.
Browse files Browse the repository at this point in the history
Fix #844
  • Loading branch information
mgautierfr committed Dec 8, 2023
1 parent abf7c11 commit e821e91
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
14 changes: 14 additions & 0 deletions include/zim/archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,20 @@ namespace zim
*/
bool hasNewNamespaceScheme() const;

/** Get if the zim archive may have alias entries.
*
* Alias entries are entries (two at least) pointing to the same
* content (same cluster/blob id).
*
* 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;

/** Get a shared ptr on the FileImpl
*
* @internal
Expand Down
5 changes: 5 additions & 0 deletions src/archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,11 @@ namespace zim
return m_impl->hasNewNamespaceScheme();
}

bool Archive::mayHaveAliasEntry() const

Check warning on line 490 in src/archive.cpp

View check run for this annotation

Codecov / codecov/patch

src/archive.cpp#L490

Added line #L490 was not covered by tests
{
return m_impl->mayHaveAliasEntry();

Check warning on line 492 in src/archive.cpp

View check run for this annotation

Codecov / codecov/patch

src/archive.cpp#L492

Added line #L492 was not covered by tests
}

cluster_index_type Archive::getClusterCount() const
{
return cluster_index_type(m_impl->getCountClusters());
Expand Down
2 changes: 1 addition & 1 deletion src/fileheader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace zim
const uint32_t Fileheader::zimMagic = 0x044d495a; // ="ZIM^d"
const uint16_t Fileheader::zimOldMajorVersion = 5;
const uint16_t Fileheader::zimMajorVersion = 6;
const uint16_t Fileheader::zimMinorVersion = 1;
const uint16_t Fileheader::zimMinorVersion = 2;
const offset_type Fileheader::size = 80; // This is also mimeListPos (so an offset)

void Fileheader::write(int out_fd) const
Expand Down
4 changes: 4 additions & 0 deletions src/fileimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,10 @@ class Grouping
return zimReader->size();
}

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

Check warning on line 603 in src/fileimpl.cpp

View check run for this annotation

Codecov / codecov/patch

src/fileimpl.cpp#L602-L603

Added lines #L602 - L603 were not covered by tests
}

bool FileImpl::is_multiPart() const {
return zimFile->is_multiPart();
}
Expand Down
1 change: 1 addition & 0 deletions src/fileimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ namespace zim
zsize_t getFilesize() const;
bool hasNewNamespaceScheme() const { return m_newNamespaceScheme; }
bool hasFrontArticlesIndex() const { return m_hasFrontArticlesIndex; }
bool mayHaveAliasEntry() const;

FileCompound::PartRange getFileParts(offset_t offset, zsize_t size);
std::shared_ptr<const Dirent> getDirent(entry_index_t idx);
Expand Down

0 comments on commit e821e91

Please sign in to comment.