Skip to content

Commit

Permalink
Rename addClone to addAlias.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgautierfr committed Nov 3, 2023
1 parent ed85541 commit 4d80e13
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions include/zim/writer/creator.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,28 +197,28 @@ namespace zim


/**
* Add a clone of a existing entry.
* Add a alias of a existing entry.
*
* The existing entry pointed by `targetPath` is cloned and updated with
* `path` and `title`.
*
* The clone entry will shared the same type (redirection or item)
* The alias entry will shared the same type (redirection or item)
* and namespace than `targetPath`.
*
* If the `targetPath` is a item, the new entry will be item pointing
* to the same data than `targetPath` item. (Not a redirection to `targetPath`).
* However, the cloned entry is not counted in the media type counter
* However, the alias entry is not counted in the media type counter
* and it is not fulltext indexed (only title indexed).
*
* Hints can be given to influence creator handling (front article, ...)
* as it is done for redirection.
*
* @param path the path of the clone
* @param title the title of the clone
* @param targetPath the path of the cloned entry.
* @param hints hints associated to the clone.
* @param path the path of the alias
* @param title the title of the alias
* @param targetPath the path of the aliased entry.
* @param hints hints associated to the alias.
*/
void addClone(
void addAlias(
const std::string& path,
const std::string& title,
const std::string& targetPath,
Expand Down
8 changes: 4 additions & 4 deletions src/writer/creator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,20 +206,20 @@ namespace zim
data->handle(dirent, hints);
}

void Creator::addClone(const std::string& path, const std::string& title, const std::string& targetPath, const Hints& hints)
void Creator::addAlias(const std::string& path, const std::string& title, const std::string& targetPath, const Hints& hints)
{
checkError();
Dirent tmpDirent(NS::C, targetPath);
auto existing_dirent_it = data->dirents.find(&tmpDirent);

if (existing_dirent_it == data->dirents.end()) {
std::ostringstream ss;
ss << "Impossible to clone C/" << targetPath << " to C/" << path << std::endl;
ss << "Impossible to alias C/" << targetPath << " as C/" << path << std::endl;
ss << "C/" << targetPath << " doesn't exist." << std::endl;
throw InvalidEntry(ss.str());
}

auto dirent = data->createCloneDirent(path, title, **existing_dirent_it);
auto dirent = data->createAliasDirent(path, title, **existing_dirent_it);
data->handle(dirent, hints);
}

Expand Down Expand Up @@ -615,7 +615,7 @@ namespace zim
return dirent;
}

Dirent* CreatorData::createCloneDirent(const std::string& path, const std::string& title, const Dirent& target)
Dirent* CreatorData::createAliasDirent(const std::string& path, const std::string& title, const Dirent& target)
{
auto dirent = pool.getCloneDirent(path, title, target);
addDirent(dirent);
Expand Down
2 changes: 1 addition & 1 deletion src/writer/creatordata.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace zim
Dirent* createDirent(NS ns, const std::string& path, const std::string& mimetype, const std::string& title);
Dirent* createItemDirent(const Item* item);
Dirent* createRedirectDirent(NS ns, const std::string& path, const std::string& title, NS targetNs, const std::string& targetPath);
Dirent* createCloneDirent(const std::string& path, const std::string& title, const Dirent& target);
Dirent* createAliasDirent(const std::string& path, const std::string& title, const Dirent& target);
Cluster* closeCluster(bool compressed);

void setEntryIndexes();
Expand Down
4 changes: 2 additions & 2 deletions test/creator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ TEST(ZimCreator, createZim)
// Be sure that title order is not the same that url order
item = std::make_shared<TestItem>("foo2", "AFoo", "Foo2Content");
creator.addItem(item);
creator.addClone("foo_bis", "The same Foo", "foo2");
creator.addAlias("foo_bis", "The same Foo", "foo2");
creator.addMetadata("Title", "This is a title");
creator.addIllustration(48, "PNGBinaryContent48");
creator.addIllustration(96, "PNGBinaryContent96");
creator.setMainPath("foo");
creator.addRedirection("foo3", "FooRedirection", "foo"); // Not a front article.
creator.addClone("foo_ter", "The same redirection", "foo3", {{ zim::writer::FRONT_ARTICLE, true}}); // a clone of the previous redirect, but as a front article.
creator.addAlias("foo_ter", "The same redirection", "foo3", {{ zim::writer::FRONT_ARTICLE, true}}); // a clone of the previous redirect, but as a front article.
creator.addRedirection("foo4", "FooRedirection", "NoExistant", {{zim::writer::FRONT_ARTICLE, true}}); // Invalid redirection, must be removed by creator
creator.finishZimCreation();

Expand Down

0 comments on commit 4d80e13

Please sign in to comment.