Merge pull request #809 from phreaker0/handle-same-second-bookmarks

support bookmarks which are taken in the same second
This commit is contained in:
Jim Salter 2023-04-26 13:49:37 -04:00 committed by GitHub
commit f8ff5ab0c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 2 deletions

20
syncoid
View File

@ -1753,6 +1753,7 @@ sub getbookmarks() {
# as though each were an entirely separate get command.
my $lastguid;
my %creationtimes=();
foreach my $line (@rawbookmarks) {
# only import bookmark guids, creation from the specified filesystem
@ -1769,7 +1770,24 @@ sub getbookmarks() {
$creation =~ s/^.*\tcreation\t*(\d*).*/$1/;
my $bookmark = $line;
$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;
}
}