On Thursday 05 June 2003 00:03, Christophe Beauregard wrote: > I've been pounding away at a pair of mail conduits Still. mbox-inbox had some minor locking problems. send-mail was stupid in how it downloads the contents of the entire database. dlp_ReadNextModifiedRecInCategory is the most efficient way to sync a database, isn't it? Unfortunately, it wasn't implemented. Patch against CVS attached. Also attached are fixed/latest versions of mail conduits, although you'll need the dlp_ReadNextModified patch for send-mail to work. On a completely unrelated note... am I correct in my understanding that coldsync doesn't do any kind of locking on the database files while synching is going on? I ask this because I'm working on a conduit which would benefit from just being able to go in and update the database in .palm/backup. It would, at the least, eliminate the need for any intermediate storage and the entire fetch conduit stage. However, it's only feasible if coldsync and I aren't messing with the same file. c.
Index: perl/ColdSync/ColdSync/SPC.pm =================================================================== RCS file: /var/lib/cvs/coldsync/perl/ColdSync/ColdSync/SPC.pm,v retrieving revision 1.19 diff -u -r1.19 SPC.pm --- perl/ColdSync/ColdSync/SPC.pm 9 Nov 2002 21:04:36 -0000 1.19 +++ perl/ColdSync/ColdSync/SPC.pm 6 Jun 2003 01:01:18 -0000 @@ -225,6 +225,8 @@ dlp_DeleteAllRecords dlp_WriteRecord dlp_SetDBInfo + dlp_ReadNextModifiedRec + dlp_ReadNextModifiedRecInCategory ); Exporter::export_ok_tags('dlp_vfs', 'dlp_args', 'dlp_expslot'); @@ -1278,6 +1280,86 @@ return $retval; } +=head2 dlp_ReadNextModifiedRec + + $record = dlp_ReadNextModifiedRec($dbh); + +Returns a reference to a hash containing information about the next +modified record in the database (since last sync). Fields returned +are the same as dlp_ReadRecord. Returns undef when no more modified records +are available. + +=head2 dlp_ReadNextModifiedRecInCategory + + $record = dlp_ReadNextModifiedRecInCategory($dbh,$catno); + +Returns a reference to a hash containing information about the next +modified record in the database matching the specified category. +Fields returned are the same as dlp_ReadRecord. Returns undef when no +more modified records are available. + +=cut +#' +sub dlp_ReadNextModifiedRec { + return dlp_ReadNextModifiedRecInCategory( @_ ); +} + +sub dlp_ReadNextModifiedRecInCategory { + my ($dbh,$catno) = @_; + my ($err, @argv); + + if (defined $catno) { + ($err, @argv) = dlp_req( DLPCMD_ReadNextModifiedRecInCategory, + { + 'id' => dlpFirstArgID, + 'data' => pack("C C", $dbh, $catno) + }); + } else { + ($err, @argv) = dlp_req( DLPCMD_ReadNextModifiedRec, + { + 'id' => dlpFirstArgID, + 'data' => pack("C", $dbh), + }); + } + + # err is non zero when we reach the last record + return undef unless defined $err or $err != 0; + + my $retval = {}; + + for (@argv) { + if ($_->{'id'} == dlpFirstArgID) { + @$retval{ + 'id', + 'index', + 'size', + 'attrs', + 'category', + 'data', + } = unpack("N n n C C a*", $_->{'data'}); + + $retval->{'attributes'}{'deleted'} = + $retval->{'attrs'} & 0x80 ? 1 : 0; + + $retval->{'attributes'}{'dirty'} = + $retval->{'attrs'} & 0x40 ? 1 : 0; + + $retval->{'attributes'}{'busy'} = + $retval->{'attrs'} & 0x20 ? 1 : 0; + + $retval->{'attributes'}{'secret'} = + $retval->{'attrs'} & 0x10 ? 1 : 0; + + $retval->{'attributes'}{'archived'} = + $retval->{'attrs'} & 0x08 ? 1 : 0; + + my $recsize = length($retval->{'data'}); + } + } + + return undef unless defined $retval->{id}; + return $retval; +} sub dlp_WriteRecord
Attachment:
send-mail
Description: Perl program
Attachment:
mbox-inbox
Description: Perl program