[SCM] Akonadi packaging branch, master, updated. debian/1.10.3-1-11-g44b8950

Maximiliano Curia maxy at moszumanska.debian.org
Fri Dec 6 20:12:56 UTC 2013


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-req/akonadi.git;a=commitdiff;h=abdb92a

The following commit has been merged in the master branch:
commit abdb92abeef6c5ef297e8f2da0a2b80c08ef7e02
Author: Maximiliano Curia <maxy at debian.org>
Date:   Fri Dec 6 18:26:55 2013 +0100

    New upstream patch: always_verify_writing_data_to_external_file.diff
---
 debian/changelog                                   |   1 +
 ...lways_verify_writing_data_to_external_file.diff | 150 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 3 files changed, 152 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 4b098b5..f23ad1f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,7 @@ akonadi (1.11.0-1) UNRELEASED; urgency=low
   * Add libxml2-utils to the build deps, to be used in the tests.
   * Bump Standards-Version to 3.9.5, no changes needed.
   * New upstream patch: dont_do_redundant_flag_changes.diff
+  * New upstream patch: always_verify_writing_data_to_external_file.diff
 
  -- Maximiliano Curia <maxy at debian.org>  Fri, 06 Dec 2013 16:24:12 +0100
 
diff --git a/debian/patches/always_verify_writing_data_to_external_file.diff b/debian/patches/always_verify_writing_data_to_external_file.diff
new file mode 100644
index 0000000..c26b59b
--- /dev/null
+++ b/debian/patches/always_verify_writing_data_to_external_file.diff
@@ -0,0 +1,150 @@
+commit 40e7cff2c75a7ba986f9ab0ab5171dc899c57b39
+Author: Dan Vrátil <dvratil at redhat.com>
+Date:   Fri Dec 6 17:08:39 2013 +0100
+
+    Always verify writing data to external file was successfull
+    
+    Always make sure that QFile::write() has written all data to prevent data
+    loss in case we run out of disk space.
+    
+    BUG: 283692
+    FIXED-IN: 1.11.1
+
+diff --git a/server/src/handler/append.cpp b/server/src/handler/append.cpp
+index 6746a41..14930fb 100644
+--- a/server/src/handler/append.cpp
++++ b/server/src/handler/append.cpp
+@@ -62,22 +62,16 @@ bool Append::commit()
+       m_size = qMax( m_size, dataSize );
+       storeInFile = dataSize > DbConfig::configuredDatabase()->sizeThreshold();
+       if ( storeInFile ) {
+-        if ( !tmpFile.open() ) {
+-          storeInFile =  false;
++        try {
++          PartHelper::streamToFile( m_streamParser, tmpFile );
++        } catch ( const PartHelperException &e ) {
++          return failureResponse( e.what() );
+         }
+-      }
+-      while ( !m_streamParser->atLiteralEnd() ) {
+-        if ( !storeInFile ) {
++      } else {
++        while ( !m_streamParser->atLiteralEnd() ) {
+           m_data += m_streamParser->readLiteralPart();
+-        } else {
+-          m_data = m_streamParser->readLiteralPart();
+-          tmpFile.write( m_data );
+         }
+       }
+-      if ( storeInFile ) {
+-        tmpFile.close();
+-        m_data = "";
+-      }
+     } else {
+       m_data = m_streamParser->readString();
+     }
+diff --git a/server/src/handler/store.cpp b/server/src/handler/store.cpp
+index 262f4c9..19d3559 100644
+--- a/server/src/handler/store.cpp
++++ b/server/src/handler/store.cpp
+@@ -302,17 +302,11 @@ bool Store::parseStream()
+ 
+           //the actual streaming code for the remaining parts:
+           // reads from the parser, writes immediately to the file
+-          // ### move this entire block to part helper? should be useful for append as well
+-          const QString fileName = PartHelper::resolveAbsolutePath( part.data() );
+-          QFile file( fileName );
+-          if ( file.open( QIODevice::WriteOnly | QIODevice::Append ) ) {
+-            while ( !m_streamParser->atLiteralEnd() ) {
+-              value = m_streamParser->readLiteralPart();
+-              file.write( value ); // ### error handling?
+-            }
+-            file.close();
+-          } else {
+-            return failureResponse( "Unable to update item part" );
++          QFile partFile( PartHelper::resolveAbsolutePath( part.data() ) );
++          try {
++            PartHelper::streamToFile( m_streamParser, partFile, QIODevice::WriteOnly | QIODevice::Append );
++          } catch ( const PartHelperException &e ) {
++            return failureResponse( e.what() );
+           }
+ 
+           changes << partName;
+diff --git a/server/src/storage/parthelper.cpp b/server/src/storage/parthelper.cpp
+index 67a9ecc..d510a56 100644
+--- a/server/src/storage/parthelper.cpp
++++ b/server/src/storage/parthelper.cpp
+@@ -23,6 +23,7 @@
+ #include "entities.h"
+ #include "selectquerybuilder.h"
+ #include "dbconfig.h"
++#include "imapstreamparser.h"
+ #include <akstandarddirs.h>
+ #include <libs/xdgbasedirs_p.h>
+ 
+@@ -201,6 +202,31 @@ void PartHelper::removeFile( const QString &fileName )
+   QFile::remove( fileName );
+ }
+ 
++bool PartHelper::streamToFile( ImapStreamParser* streamParser, QFile &file, QIODevice::OpenMode openMode )
++{
++  Q_ASSERT( openMode & QIODevice::WriteOnly );
++
++  if ( !file.isOpen() ) {
++    if ( !file.open( openMode ) ) {
++      throw PartHelperException( "Unable to update item part" );
++    }
++  } else {
++    Q_ASSERT( file.openMode() & QIODevice::WriteOnly );
++  }
++
++  QByteArray value;
++  while ( !streamParser->atLiteralEnd() ) {
++    value = streamParser->readLiteralPart();
++    if ( file.write( value ) != value.size() ) {
++      throw PartHelperException( "Unable to write payload to file" );
++    }
++  }
++  file.close();
++
++  return true;
++}
++
++
+ QByteArray PartHelper::translateData( const QByteArray &data, bool isExternal )
+ {
+   if ( isExternal ) {
+diff --git a/server/src/storage/parthelper.h b/server/src/storage/parthelper.h
+index 5d1fb59..bd82ab6 100644
+--- a/server/src/storage/parthelper.h
++++ b/server/src/storage/parthelper.h
+@@ -26,10 +26,13 @@
+ 
+ class QString;
+ class QVariant;
++class QFile;
+ 
+ namespace Akonadi
+ {
+ 
++class ImapStreamParser;
++
+ AKONADI_EXCEPTION_MAKE_INSTANCE( PartHelperException );
+ 
+ /**
+@@ -67,6 +70,15 @@ namespace PartHelper
+    */
+   void removeFile( const QString &fileName );
+ 
++  /**
++   * Reads data from @p streamParser as they arrive from client and writes them
++   * to @p partFile. It will close the file when all data are read.
++   *
++   * @param partFile File to write into. The file must be closed, or opened in write mode
++   * @throws PartHelperException when an error occurs (write fails, data truncated, etc)
++   */
++  bool streamToFile( ImapStreamParser *streamParser, QFile &partFile, QIODevice::OpenMode = QIODevice::WriteOnly );
++
+   /** Returns the payload data. */
+   QByteArray translateData( const QByteArray &data, bool isExternal );
+   /** Convenience overload of the above. */
diff --git a/debian/patches/series b/debian/patches/series
index ba9f3e3..f100291 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 # disable_dbus_requiring_tests.diff
 dont_do_redundant_flag_changes.diff
+always_verify_writing_data_to_external_file.diff

-- 
Akonadi packaging



More information about the pkg-kde-commits mailing list