commit 5cd1f29a89b6fa4e3fc41d5168926a47fbb68123
Author: Oswald Buddenhagen <o...@kde.org>
Date:   Mon Jul 25 09:25:09 2011 +0200

    suppress bdb complaints about unknown file format
    
    pass DB_TRUNCATE when creating databases. otherwise bdb will complain
    about the empty file we pass it (we have to create it upfront to
    implement our locking).

 src/drv_maildir.c |   11 ++++++++++-
 src/mdconvert.c   |    2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/drv_maildir.c b/src/drv_maildir.c
index 24aae2d..6013846 100644
--- a/src/drv_maildir.c
+++ b/src/drv_maildir.c
@@ -803,6 +803,9 @@ maildir_select( store_t *gctx, int create,
 {
        maildir_store_t *ctx = (maildir_store_t *)gctx;
        int ret;
+#ifdef USE_DB
+       struct stat st;
+#endif /* USE_DB */
        char uvpath[_POSIX_PATH_MAX];
 
        maildir_cleanup( gctx );
@@ -855,12 +858,18 @@ maildir_select( store_t *gctx, int create,
                        cb( DRV_BOX_BAD, aux );
                        return;
                }
+               if (fstat( ctx->uvfd, &st )) {
+                       sys_error( "Maildir error: cannot stat %s", uvpath );
+                       cb( DRV_BOX_BAD, aux );
+                       return;
+               }
                if (db_create( &ctx->db, 0, 0 )) {
                        fputs( "Maildir error: db_create() failed\n", stderr );
                        cb( DRV_BOX_BAD, aux );
                        return;
                }
-               if ((ret = (ctx->db->open)( ctx->db, 0, uvpath, 0, DB_HASH, 
DB_CREATE, 0 ))) {
+               if ((ret = (ctx->db->open)( ctx->db, 0, uvpath, 0, DB_HASH,
+                                           st.st_size ? 0 : DB_CREATE | 
DB_TRUNCATE, 0 ))) {
                        ctx->db->err( ctx->db, ret, "Maildir error: 
db->open(%s)", uvpath );
                        cb( DRV_BOX_BAD, aux );
                        return;
diff --git a/src/mdconvert.c b/src/mdconvert.c
index 48bd759..7dbfb48 100644
--- a/src/mdconvert.c
+++ b/src/mdconvert.c
@@ -122,7 +122,7 @@ convert( const char *box, int altmap )
                fputs( "Error: db_create() failed\n", stderr );
                goto tbork;
        }
-       if ((ret = (db->open)( db, 0, dbpath, 0, DB_HASH, DB_CREATE, 0 ))) {
+       if ((ret = (db->open)( db, 0, dbpath, 0, DB_HASH, altmap ? 
DB_CREATE|DB_TRUNCATE : 0, 0 ))) {
                db->err( db, ret, "Error: db->open(%s)", dbpath );
          dbork:
                db->close( db, 0 );

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to