Skip to content

Commit

Permalink
fix: description images are not removed anymore from a newly created …
Browse files Browse the repository at this point in the history
…package (Mudlet#5377)

pattern change of regex was needed to prevent the removal of all images which took place due to changes in the image pattern
  • Loading branch information
Edru2 authored Aug 16, 2021
1 parent df648f1 commit 869b681
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dlgPackageExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ QString dlgPackageExporter::copyNewImagesToTmp(const QString& tempPath) const
// purge images from tmp which are no longer used by the description
void dlgPackageExporter::cleanupUnusedImages(const QString& tempPath, const QString& plainDescription)
{
static QRegularExpression imagesInUsePattern(R"(\$packagePath\/\.mudlet\/description_images\/(.+?)\")");
static QRegularExpression imagesInUsePattern(R"(\$packagePath\/\.mudlet\/description_images\/(.+?)\.)");
QStringList imagesInUse;
QRegularExpressionMatchIterator i = imagesInUsePattern.globalMatch(plainDescription);
while (i.hasNext()) {
Expand All @@ -645,7 +645,7 @@ void dlgPackageExporter::cleanupUnusedImages(const QString& tempPath, const QStr
QDirIterator allImagesCopied(QStringLiteral("%1.mudlet/description_images").arg(tempPath), QDir::Files);
while (allImagesCopied.hasNext()) {
QFileInfo copiedImage(allImagesCopied.next());
if (!imagesInUse.contains(copiedImage.fileName())) {
if (!imagesInUse.contains(copiedImage.baseName())) {
if (!QFile(copiedImage.absoluteFilePath()).remove()) {
qDebug() << "couldn't remove unused image" << copiedImage.fileName();
}
Expand Down

0 comments on commit 869b681

Please sign in to comment.