Subject: | patch to put deleted record last, in PDB.pm |
Date: | Wed, 21 Jan 2015 13:31:35 -0600 |
To: | bug-Palm-PDB [...] rt.cpan.org |
From: | Alan Wehmann <alan.wehmann [...] gmail.com> |
I note that for a SmartList-To-Go database, deleted records are all located after the ones that aren't deleted. This is true even in the case that records are added to a database that has deleted records (where the records are added on the handheld).
PDB.pm puts appended records at the end of all records that were read in & it took me a while to realize that SLTG wants added records to come before the deleted ones. It makes this rearrangement itself (as noted in the previous paragraph--when records are added (on the handheld) to a database that contains deleted records).
Below I include my patch to fix this problem:
--- /opt/local/lib/perl5/site_perl/5.16.3/Palm/original/PDB.pm 2014-08-09 14:47:03.000000000 -0500
+++ /opt/local/lib/perl5/site_perl/5.16.3/Palm/original/fixed/PDB.pm 2015-01-21 13:26:47.000000000 -0600
@@ -723,6 +723,7 @@
my $self = shift;
my $fname = shift; # Output file name
my @record_data;
+ my @temp_data;
die "Can't write a database with no name\n"
unless $self->{name} ne "";
@@ -804,9 +805,16 @@
$id = $record->{id};
$data = $self->PackRecord($record);
+ if ($attributes & 0x80) {
+ push @temp_data, [ $attributes, $id, $data ];
+ }
+ else {
+ push @record_data, [ $attributes, $id, $data ];
+ }
- push @record_data, [ $attributes, $id, $data ];
}
+ # put deleted records at end
+ push @record_data, @temp_data;
# Figure out size of index
$index_len = RecIndexHeaderLen +
($#record_data + 1) * IndexRecLen;