-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
syncoid: Compare existing bookmarks #626
base: master
Are you sure you want to change the base?
Conversation
a478599
to
7e76de6
Compare
@jimsalterjrs @phreaker0 Ping |
7e76de6
to
2979a7e
Compare
2979a7e
to
fd449dd
Compare
I think a better way to handle this would be to check the bookmark on failure if it already exists and points to the correct snapshot and if not still fail. So there wouldn't be the need for an extra argument and one can be sure that the bookmark is correct. |
When creating bookmarks compare the GUID of existing bookmarks before failing the creation of a duplicate bookmark. Signed-off-by: 0xFelix <[email protected]>
fd449dd
to
dd244de
Compare
@phreaker0 Makes sense! Updated the PR to implement that. |
Also ping @jimsalterjrs |
if (defined $args{'create-bookmark'}) { | ||
my $ret = createbookmark($sourcehost, $sourcefs, $newsyncsnap, $newsyncsnap); | ||
my %existingbookmarks = getbookmarks($sourcehost,$sourcefs,$sourceisroot); | ||
my $guid = $snaps{'source'}{$newsyncsnap}{'guid'}; | ||
my $ret = createbookmark($sourcehost, $sourcefs, $newsyncsnap, $newsyncsnap, $guid, %existingbookmarks); | ||
$ret == 0 or do { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code should stay as it where before, because doing it this way will degrade performance because each time all the bookmarks needs to be listed.
It's better to handle that in the fallback case (if the bookmark creation fails), there the bookmark listing and the compare if this bookmark already exists should be made.
my ($sourcehost, $sourcefs, $snapname, $bookmark, $guid, %existingbookmarks) = @_; | ||
|
||
if (defined $existingbookmarks{$guid} && $existingbookmarks{$guid}{'name'} eq $bookmark) { | ||
writelog('INFO', "bookmark already exists, skipping creation"); | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be move to the fallback case if the bookmark creation failed
@@ -0,0 +1,93 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because of #904 this needs to be renamed with a 0 prefix.
When creating bookmarks compare the GUID of existing bookmarks before
failing the creation of a duplicate bookmark.