support bookmarks which are taken in the same second

This commit is contained in:
Christoph Klaffl 2023-03-24 09:00:07 +01:00
parent 86fffca306
commit 91d96a4c87
No known key found for this signature in database
GPG Key ID: 8FC1D76EED4970D2
1 changed files with 20 additions and 2 deletions

20
syncoid
View File

@ -1729,6 +1729,7 @@ sub getbookmarks() {
# as though each were an entirely separate get command. # as though each were an entirely separate get command.
my $lastguid; my $lastguid;
my %creationtimes=();
foreach my $line (@rawbookmarks) { foreach my $line (@rawbookmarks) {
# only import bookmark guids, creation from the specified filesystem # only import bookmark guids, creation from the specified filesystem
@ -1745,7 +1746,24 @@ sub getbookmarks() {
$creation =~ s/^.*\tcreation\t*(\d*).*/$1/; $creation =~ s/^.*\tcreation\t*(\d*).*/$1/;
my $bookmark = $line; my $bookmark = $line;
$bookmark =~ s/^.*\#(.*)\tcreation.*$/$1/; $bookmark =~ s/^.*\#(.*)\tcreation.*$/$1/;
$bookmarks{$lastguid}{'creation'}=$creation . "000";
# the accuracy of the creation timestamp is only for a second, but
# bookmarks in the same second are possible. The list command
# has an ordered output so we append another three digit running number
# to the creation timestamp and make sure those are ordered correctly
# for bookmarks with the same creation timestamp
my $counter = 0;
my $creationsuffix;
while ($counter < 999) {
$creationsuffix = sprintf("%s%03d", $creation, $counter);
if (!defined $creationtimes{$creationsuffix}) {
$creationtimes{$creationsuffix} = 1;
last;
}
$counter += 1;
}
$bookmarks{$lastguid}{'creation'}=$creationsuffix;
} }
} }