mirror of
https://codeberg.org/scip/note.git
synced 2025-12-16 20:21:04 +01:00
changed ::pwsafe3 note id generation
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
1.3.21:
|
||||||
|
Changed note id generation in NOTEDB::pwsafe3::_uuid(), again.
|
||||||
|
Instead of crc checksums and the loop to avoid duplicates, I just
|
||||||
|
use a counter and sort the entries by ctime, so that older entries
|
||||||
|
keep their note id. Also this should fix a rare bug, where the
|
||||||
|
code hangs because of said loop.
|
||||||
|
================================================================================
|
||||||
1.3.20:
|
1.3.20:
|
||||||
fixed bug in NOTEDB::pwsafe3::_retrieve(), it iterated over the
|
fixed bug in NOTEDB::pwsafe3::_retrieve(), it iterated over the
|
||||||
records unsorted which resulted in different note ids each time
|
records unsorted which resulted in different note ids each time
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ package NOTEDB;
|
|||||||
use Exporter ();
|
use Exporter ();
|
||||||
use vars qw(@ISA @EXPORT $crypt_supported);
|
use vars qw(@ISA @EXPORT $crypt_supported);
|
||||||
|
|
||||||
$NOTEDB::VERSION = "1.41";
|
$NOTEDB::VERSION = "1.42";
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
# make sure, it works, otherwise encryption
|
# make sure, it works, otherwise encryption
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
package NOTEDB::pwsafe3;
|
package NOTEDB::pwsafe3;
|
||||||
|
|
||||||
$NOTEDB::pwsafe3::VERSION = "1.06";
|
$NOTEDB::pwsafe3::VERSION = "1.07";
|
||||||
use lib qw(/home/scip/D/github/Crypt--PWSafe3/blib/lib);
|
|
||||||
use strict;
|
use strict;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use Time::Local;
|
use Time::Local;
|
||||||
@@ -324,7 +323,7 @@ sub _retrieve {
|
|||||||
|
|
||||||
my @records = $vault->getrecords();
|
my @records = $vault->getrecords();
|
||||||
|
|
||||||
foreach my $record (sort { $a->uuid cmp $b->uuid } @records) {
|
foreach my $record (sort { $a->ctime <=> $b->ctime } @records) {
|
||||||
my $num = $this->_uuid( $record->uuid );
|
my $num = $this->_uuid( $record->uuid );
|
||||||
my %entry = (
|
my %entry = (
|
||||||
uuid => $record->uuid,
|
uuid => $record->uuid,
|
||||||
@@ -450,34 +449,23 @@ sub _notetopwsafe3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub _uuid {
|
sub _uuid {
|
||||||
#
|
|
||||||
# Convert a given pwsafe3 uuid to a number
|
|
||||||
# and store them for recursive access
|
|
||||||
my ($this, $uuid) = @_;
|
my ($this, $uuid) = @_;
|
||||||
if (exists $this->{uuidnum}->{$uuid}) {
|
if (exists $this->{uuidnum}->{$uuid}) {
|
||||||
return $this->{uuidnum}->{$uuid};
|
return $this->{uuidnum}->{$uuid};
|
||||||
}
|
}
|
||||||
|
|
||||||
my $intuuid = $uuid;
|
my $max = 0;
|
||||||
$intuuid =~ s/[\-]//g;
|
|
||||||
$intuuid = unpack('h32', $intuuid);
|
if (exists $this->{numuuid}) {
|
||||||
my $cuid = $intuuid;
|
$max = (sort { $b <=> $a } keys %{$this->{numuuid}})[0];
|
||||||
my $checksum;
|
|
||||||
while () {
|
|
||||||
$checksum = unpack("%16C*", $cuid) - 1600;
|
|
||||||
while ($checksum < 0) {
|
|
||||||
$checksum++; # avoid negative numbers
|
|
||||||
}
|
|
||||||
if (! exists $this->{numuuid}->{$checksum}) {
|
|
||||||
$this->{uuidnum}->{$uuid} = $checksum;
|
|
||||||
$this->{numuuid}->{$checksum} = $uuid;
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$cuid .= $.;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $checksum;
|
|
||||||
|
my $num = $max + 1;
|
||||||
|
|
||||||
|
$this->{uuidnum}->{$uuid} = $num;
|
||||||
|
$this->{numuuid}->{$num} = $uuid;
|
||||||
|
|
||||||
|
return $num;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _getuuid {
|
sub _getuuid {
|
||||||
|
|||||||
2
bin/note
2
bin/note
@@ -144,7 +144,7 @@ $CONF = File::Spec->catfile($ENV{HOME}, ".noterc");
|
|||||||
$USER = getlogin || getpwuid($<);
|
$USER = getlogin || getpwuid($<);
|
||||||
chomp $USER;
|
chomp $USER;
|
||||||
$TOPIC = 1;
|
$TOPIC = 1;
|
||||||
$version = "1.3.20";
|
$version = "1.3.21";
|
||||||
$CurDepth = 1; # the current depth inside the topic "directory" structure...
|
$CurDepth = 1; # the current depth inside the topic "directory" structure...
|
||||||
$maxlen = "auto";
|
$maxlen = "auto";
|
||||||
$timelen = 22;
|
$timelen = 22;
|
||||||
|
|||||||
Reference in New Issue
Block a user