[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepim-runtime] resources: Improve error handling (fixes after review).
From: Andras Mantia <amantia () kde ! org>
Date: 2013-11-15 20:18:49
Message-ID: E1VhPqr-0003Cb-Qi () scm ! kde ! org
[Download RAW message or body]
Git commit e38b776219bc0af6b06eff34a502cb4c80f232b4 by Andras Mantia.
Committed on 15/11/2013 at 20:18.
Pushed by amantia into branch 'master'.
Improve error handling (fixes after review).
REVIEW: 113890
M +6 -7 resources/maildir/libmaildir/maildir.cpp
M +9 -5 resources/mixedmaildir/mixedmaildirstore.cpp
http://commits.kde.org/kdepim-runtime/e38b776219bc0af6b06eff34a502cb4c80f232b4
diff --git a/resources/maildir/libmaildir/maildir.cpp \
b/resources/maildir/libmaildir/maildir.cpp index 712994d..dc202cc 100644
--- a/resources/maildir/libmaildir/maildir.cpp
+++ b/resources/maildir/libmaildir/maildir.cpp
@@ -559,10 +559,9 @@ bool Maildir::writeEntry( const QString& key, const QByteArray& \
data ) d->lastError = i18n( "Cannot locate mail file %1." ).arg( key );
return false;
}
- bool result;
QFile f( realKey );
- result = f.open( QIODevice::WriteOnly );
- result &= ( f.write( data ) != -1 );
+ bool result = f.open( QIODevice::WriteOnly );
+ result = result & ( f.write( data ) != -1 );
f.close();
if ( !result) {
d->lastError = i18n( "Cannot write to mail file %1." ).arg( realKey );
@@ -587,10 +586,9 @@ QString Maildir::addEntry( const QByteArray& data )
curKey = d->path + QLatin1String( "/cur/" ) + uniqueKey;
} while ( QFile::exists( key ) || QFile::exists( finalKey ) || QFile::exists( \
curKey ) );
- bool result;
QFile f( key );
- result = f.open( QIODevice::WriteOnly );
- result &= ( f.write( data ) != -1 );
+ bool result = f.open( QIODevice::WriteOnly );
+ result = result & ( f.write( data ) != -1 );
f.close();
if ( !result) {
d->lastError = i18n( "Cannot write to mail file %1." ).arg( key );
@@ -699,7 +697,7 @@ QString Maildir::changeEntryFlags(const QString& key, const \
Akonadi::Item::Flags
if ( !f.rename( finalKey ) ) {
qWarning() << "Maildir: Failed to rename entry: " << f.fileName() << " to " \
<< finalKey << "! Error: " << f.errorString();
- d->lastError = i18n("Failed to update the file name %1 to %2 on the disk. \
The error was: %3.").arg(f.fileName()).arg(finalKey).arg(f.errorString()); + \
d->lastError = i18n( "Failed to update the file name %1 to %2 on the disk. The error \
was: %3." ).arg( f.fileName(), finalKey, f.errorString() ); return QString();
}
@@ -774,6 +772,7 @@ QString Maildir::moveEntryTo( const QString &key, const Maildir \
&destination ) {
const QString realKey( d->findRealKey( key ) );
if ( realKey.isEmpty() ) {
+ kWarning() << "Unable to find: " << key;
d->lastError = i18n( "Cannot locate mail file %1." ).arg( key );
return QString();
}
diff --git a/resources/mixedmaildir/mixedmaildirstore.cpp \
b/resources/mixedmaildir/mixedmaildirstore.cpp index 80f5735..103dcdd 100644
--- a/resources/mixedmaildir/mixedmaildirstore.cpp
+++ b/resources/mixedmaildir/mixedmaildirstore.cpp
@@ -318,10 +318,11 @@ class MaildirContext
QString addEntry( const QByteArray &data ) {
const QString result = mMaildir.addEntry( data );
if ( !result.isEmpty() && mHasIndexData ) {
- //TODO: use the error string?
- kWarning() << mMaildir.lastError();
mIndexData.insert( result, KMIndexDataPtr( new KMIndexData ) );
Q_ASSERT( mIndexData.value( result )->isEmpty() );
+ } else {
+ //TODO: use the error string?
+ kWarning() << mMaildir.lastError();
}
return result;
@@ -346,8 +347,6 @@ class MaildirContext
QString moveEntryTo( const QString &key, MaildirContext &destination ) {
const QString result = mMaildir.moveEntryTo( key, destination.mMaildir );
if ( !result.isEmpty() ) {
- //TODO error handling?
- kWarning() << mMaildir.lastError();
if ( mHasIndexData ) {
mIndexData.remove( key );
}
@@ -355,6 +354,9 @@ class MaildirContext
if ( destination.mHasIndexData ) {
destination.mIndexData.insert( result, KMIndexDataPtr( new KMIndexData ) \
); }
+ } else {
+ //TODO error handling?
+ kWarning() << mMaildir.lastError();
}
return result;
@@ -370,7 +372,9 @@ class MaildirContext
bool isValid( QString &error ) const {
bool result = mMaildir.isValid();
- if ( !result ) error = mMaildir.lastError();
+ if ( !result ) {
+ error = mMaildir.lastError();
+ }
return result;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic