Commit 177cc517 authored by Laurent Montel's avatar Laurent Montel 😁

Avoid double check about empty directory

parent 16d47d15
......@@ -74,9 +74,7 @@ void FilterBalsa::import()
}
// Select directory from where I have to import files
const QString maildir = QFileDialog::getExistingDirectory(0, QString(), balsaDir);
if (!maildir.isEmpty()) {
importMails(maildir);
}
importMails(maildir);
}
void FilterBalsa::processDirectory(const QString &path)
......@@ -100,16 +98,16 @@ void FilterBalsa::processDirectory(const QString &path)
void FilterBalsa::importMails(const QString &maildir)
{
setMailDir(maildir);
if (mailDir().isEmpty()) {
if (maildir.isEmpty()) {
filterInfo()->alert(i18n("No directory selected."));
return;
}
setMailDir(maildir);
/**
* If the user only select homedir no import needed because
* there should be no files and we surely import wrong files.
*/
else if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
filterInfo()->addErrorLogEntry(i18n("No files found for import."));
} else {
filterInfo()->setOverall(0);
......
......@@ -60,17 +60,16 @@ void FilterEvolution::import()
void FilterEvolution::importMails(const QString &maildir)
{
setMailDir(maildir);
if (mailDir().isEmpty()) {
if (maildir.isEmpty()) {
filterInfo()->alert(i18n("No directory selected."));
return;
}
setMailDir(maildir);
/**
* If the user only select homedir no import needed because
* there should be no files and we surely import wrong files.
*/
else if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
filterInfo()->addErrorLogEntry(i18n("No files found for import."));
} else {
filterInfo()->setOverall(0);
......
......@@ -81,16 +81,16 @@ bool FilterEvolution_v2::excludeFiles(const QString &file)
void FilterEvolution_v2::importMails(const QString &maildir)
{
setMailDir(maildir);
if (mailDir().isEmpty()) {
if (maildir.isEmpty()) {
filterInfo()->alert(i18n("No directory selected."));
return;
}
setMailDir(maildir);
/**
* If the user only select homedir no import needed because
* there should be no files and we surely import wrong files.
*/
else if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
filterInfo()->addErrorLogEntry(i18n("No files found for import."));
} else {
filterInfo()->setOverall(0);
......
......@@ -95,16 +95,16 @@ void FilterEvolution_v3::processDirectory(const QString &path)
void FilterEvolution_v3::importMails(const QString &maildir)
{
setMailDir(maildir);
if (mailDir().isEmpty()) {
if (maildir.isEmpty()) {
filterInfo()->alert(i18n("No directory selected."));
return;
}
setMailDir(maildir);
/**
* If the user only select homedir no import needed because
* there should be no files and we surely import wrong files.
*/
else if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
filterInfo()->addErrorLogEntry(i18n("No files found for import."));
} else {
filterInfo()->setOverall(0);
......
......@@ -90,16 +90,16 @@ void FilterKMail_maildir::processDirectory(const QString &path)
void FilterKMail_maildir::importMails(const QString &maildir)
{
setMailDir(maildir);
if (mailDir().isEmpty()) {
if (maildir.isEmpty()) {
filterInfo()->alert(i18n("No directory selected."));
return;
}
setMailDir(maildir);
/**
* If the user only select homedir no import needed because
* there should be no files and we surely import wrong files.
*/
else if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
filterInfo()->addErrorLogEntry(i18n("No files found for import."));
} else {
filterInfo()->setOverall(0);
......
......@@ -42,15 +42,15 @@ FilterMailmanGzip::~FilterMailmanGzip()
void FilterMailmanGzip::import()
{
const QStringList filenames = QFileDialog::getOpenFileNames(filterInfo()->parentWidget(), QString(), QDir::homePath(), i18n("gzip Files (*.txt.gz)"));
if (filenames.isEmpty()) {
filterInfo()->alert(i18n("No files selected."));
return;
}
importMails(filenames);
}
void FilterMailmanGzip::importMails(const QStringList &filenames)
{
if (filenames.isEmpty()) {
filterInfo()->alert(i18n("No files selected."));
return;
}
int currentFile = 1;
int overall_status = 0;
bool first_msg = true;
......
......@@ -43,15 +43,15 @@ FilterMBox::~FilterMBox()
void FilterMBox::import()
{
const QStringList filenames = QFileDialog::getOpenFileNames(filterInfo()->parentWidget(), QString(), QDir::homePath(), i18n("mbox Files (*.mbox)"));
if (filenames.isEmpty()) {
filterInfo()->alert(i18n("No files selected."));
return;
}
importMails(filenames);
}
void FilterMBox::importMails(const QStringList &filenames)
{
if (filenames.isEmpty()) {
filterInfo()->alert(i18n("No files selected."));
return;
}
int currentFile = 1;
int overall_status = 0;
bool first_msg = true;
......
......@@ -61,11 +61,11 @@ void FilterOE::import()
void FilterOE::importMails(const QString &maildir)
{
setMailDir(maildir);
if (mailDir().isEmpty()) { // No directory selected
if (maildir.isEmpty()) { // No directory selected
filterInfo()->alert(i18n("No directory selected."));
return;
}
setMailDir(maildir);
QDir dir(mailDir());
QStringList files = dir.entryList(QStringList(QStringLiteral("*.[dDmM][bB][xX]")), QDir::Files, QDir::Name);
......
......@@ -42,18 +42,16 @@ void FilterPMail::import()
{
// Select directory from where I have to import files
const QString maildir = QFileDialog::getExistingDirectory(0, QString(), QDir::homePath());
if (!maildir.isEmpty()) {
importMails(maildir);
}
importMails(maildir);
}
void FilterPMail::importMails(const QString &chosenDir)
{
setMailDir(chosenDir);
if (mailDir().isEmpty()) {
if (chosenDir.isEmpty()) {
filterInfo()->alert(i18n("No directory selected."));
return;
}
setMailDir(chosenDir);
// Count total number of files to be processed
filterInfo()->addInfoLogEntry(i18n("Counting files..."));
......
......@@ -126,16 +126,16 @@ void FilterSylpheed::processDirectory(const QString &path)
void FilterSylpheed::importMails(const QString &maildir)
{
setMailDir(maildir);
if (mailDir().isEmpty()) {
if (maildir.isEmpty()) {
filterInfo()->alert(i18n("No directory selected."));
return;
}
setMailDir(maildir);
/**
* If the user only select homedir no import needed because
* there should be no files and we surely import wrong files.
*/
else if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
filterInfo()->addErrorLogEntry(i18n("No files found for import."));
} else {
filterInfo()->setOverall(0);
......
......@@ -88,16 +88,16 @@ void FilterTheBat::processDirectory(const QString &path)
void FilterTheBat::importMails(const QString &maildir)
{
setMailDir(maildir);
if (mailDir().isEmpty()) {
if (maildir.isEmpty()) {
filterInfo()->alert(i18n("No directory selected."));
return;
}
setMailDir(maildir);
/**
* If the user only select homedir no import needed because
* there should be no files and we surely import wrong files.
*/
else if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
filterInfo()->addErrorLogEntry(i18n("No files found for import."));
} else {
filterInfo()->setOverall(0);
......
......@@ -148,16 +148,16 @@ bool FilterThunderbird::excludeFiles(const QString &file)
void FilterThunderbird::importMails(const QString &maildir)
{
setMailDir(maildir);
if (mailDir().isEmpty()) {
if (maildir.isEmpty()) {
filterInfo()->alert(i18n("No directory selected."));
return;
}
setMailDir(maildir);
/**
* If the user only select homedir no import needed because
* there should be no files and we surely import wrong files.
*/
else if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
if (mailDir() == QDir::homePath() || mailDir() == (QDir::homePath() + QLatin1Char('/'))) {
filterInfo()->addErrorLogEntry(i18n("No files found for import."));
} else {
filterInfo()->setOverall(0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment