Skip to content

Prepartion for batch utility for creating basket archives from source

Sebastian Engel requested to merge blu-base/basket:refactArchiver into master

There was no obvious way to extract and change the source of the provided welcome.baskets, and to re-encode them.
In this PR I want to develop a feature to allow developers to do exactly these tasks.

I would like to get you engaged in a discussion where to implement this feature.

Context

In a previous attempt, i had plainly copied the extracted basket in the global directory. However my attempt did not conserve the included data. Tags, and a few other things are not stored in the same directory as the plain text notes. In !23 (merged) we now have a brief description of how the .baskets are encoded.

Changes

src/archive.cpp contains the respective algorithm to decode and encode .baskets, namely: Archive::open and Archive::save, respectively.
The contained features are necessary to externally deal with baskets. However, these functions are bundles with the KMessageBox calls.

To avoid code duplicated, i started to refactor the Archive::open method. The previous body of that method is now to be found in Archive::extractArchive excluding the dialog box calls. I introduced an Enum to transfer information what happened back to Archive::open.

Moreover, i introduced a (stupid) function to encode an extracted .baskets file. However, this is not really validating the provided directory tree.

Discussion

  • Is touching the original method (open) the best approach, or is code duplication acceptable here. The duplicated code could be made debug only.
  • where should be the decode, encode functions be called? Would be an additional small cli tool be good, or should the main application receive additional command line parameters to allow batch operation.
  • The original decode algorithm contains a few weird if loops (look for the uninitialized `bool ok;). I guess this had some intended purpose at some point, but did not receive any further use. I guess, this could be removed, do you agree?

Every comment is welcome!

Edited by Sebastian Engel

Merge request reports