[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    Fwd: korrupte KMail-index-Dateien
From:       Stefan Taferner <taferner () kde ! org>
Date:       2000-07-31 8:44:04
[Download RAW message or body]

Hello everybody,

Martin Schulte sent me a script that helps to not loose status information
when kmail recreates the index file.

(I did not have a look at it)

--Stefan

----------  Forwarded Message  ----------
Subject: korrupte KMail-index-Dateien
Date: Sat, 29 Jul 2000 01:12:18 +0200
From: Martin Schulte <schulte@guug.de>
To: kalle@dalheimer.de,
 taferner@kde.org



Hallo Kalle, hallo Stefan,

auch wenn es mit dem neuesten KMail nicht mehr passieren sollte - falls
 nochmal jemand eine KMail-Index-Datei regenerieren will, verhindert
 beigefügtes Skript den Verlust der Status-Information.

Viele Grüße,

Martin

-------------------------------------------------------




["kmail-index-status-copy.pl" (application/x-perl)]

#!/usr/bin/perl -w
# Keep the status (read, answered, forwarded) in KMail-index-files
# after regenerating the index
# How to proceed:
# 1. mv Mail/.inbox.index old-index
# 2. start kmail
# 3. finish kmail
# 4. mv Mail/.inbox.index new-index
# 5. kmail-index-status-copy.pl old-index new-index > Mail/.inbox.index

die( "Usage: $0 source destination" ) if ( $#ARGV != 1 );

open( SOURCE_INDEX, "$ARGV[0]" ) or die( "Can't read-open $ARGV[0]\n" );

while ( <SOURCE_INDEX> ) {
  chomp;
  if ( $. == 1 ) {
    die( '# KMail in $ARGV[0] expected' ) if ( $_ !~ /\# KMail-Index / );
  } else {
    die( "len != 338 in line $. of $ARGV[0]\n" ) if ( length( $_ ) != 338 );
    $begin          = substr( $_, 2, 9 );
    $status{$begin} = substr( $_, 0, 1);    
    $len{$begin}    = substr( $_, 12, 9 );
  }
}

close ( SOURCE_INDEX);

$match = 0;
$line = 0;

open( DEST_INDEX, "$ARGV[1]" ) or die( "Can't read-open $ARGV[1]\n" );

while ( <DEST_INDEX> ) {
  if ( $. == 1 ) {
    die( '# KMail in $ARGV[1] expected' ) if ( $_ !~ /\# KMail-Index / );
    print;
  } else {
    die( "len != 339\n" ) if ( length( $_ ) != 339 );
    $status = substr( $_, 0, 1 ); 
    $begin  = substr( $_, 2, 9 );
    $len    = substr( $_, 12, 9 );
    if ( defined( $status{$begin} ) ) {
      print STDERR "Len-mismatch: $len != $len{$begin}\n" if ( $len != $len{$begin} );
      $_ = $status{$begin}.substr( $_, 1);
      $match++;
    }
    print;
    $line++;
  }
}

close( DEST_INDEX );

print STDERR "Updated $match of $line entries in $ARGV[1]\n";




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic