Sometimes, when data in LML changes, files might get moved from a directory created by rename rules. This might leave some empty directories. This change cleans up those directories after renaming.
db->log(tr("Rename: File <%1> was renamed to <%2>").arg(oldFile.canonicalFilePath()).arg(newFileString));
- // TODO cleanup empty dirs
+ QDir dir = oldFile.dir();
+ dir.setFilter(QDir::NoDotAndDotDot | QDir::AllEntries);
+ while (!dir.count())
+ {
+ if (!dir.rmdir(dir.canonicalPath()))
+ {
+ qDebug() << "Failed to remove empty directory " << dir.path();
+ break;
+ }
+ if (!dir.cdUp())
+ break;
+ }
}
emit renameBatchFinished();