diff options
Diffstat (limited to 'object/store/dual/quarantine_begin.go')
| -rw-r--r-- | object/store/dual/quarantine_begin.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/object/store/dual/quarantine_begin.go b/object/store/dual/quarantine_begin.go new file mode 100644 index 00000000..bca688b7 --- /dev/null +++ b/object/store/dual/quarantine_begin.go @@ -0,0 +1,47 @@ +package dual + +import objectstore "codeberg.org/lindenii/furgit/object/store" + +// TODO: This doesn't actually make sense. We need a combined quarantine. + +// BeginObjectQuarantine creates one coordinated dual quarantine spanning both +// stores and returns it as an object-wise quarantine. +// +// Labels: Deps-Borrowed, Life-Parent, Close-No. +func (dual *Dual) BeginObjectQuarantine(_ objectstore.ObjectQuarantineOptions) (objectstore.ObjectQuarantine, error) { + quarantine, err := dual.beginQuarantine() + if err != nil { + return nil, err + } + + return quarantine, nil +} + +// BeginPackQuarantine creates one coordinated dual quarantine spanning both +// stores and returns it as a pack-wise quarantine. +// +// Labels: Deps-Borrowed, Life-Parent, Close-No. +func (dual *Dual) BeginPackQuarantine(_ objectstore.PackQuarantineOptions) (objectstore.PackQuarantine, error) { + quarantine, err := dual.beginQuarantine() + if err != nil { + return nil, err + } + + return quarantine, nil +} + +func (dual *Dual) beginQuarantine() (*quarantine, error) { + objectQ, err := dual.object.BeginObjectQuarantine(objectstore.ObjectQuarantineOptions{}) + if err != nil { + return nil, err + } + + packQ, err := dual.pack.BeginPackQuarantine(objectstore.PackQuarantineOptions{}) + if err != nil { + _ = objectQ.Discard() + + return nil, err + } + + return newQuarantine(objectQ, packQ), nil +} |
