forked from security/hakurei
internal/pipewire: export Registry::Destroy
This handles the error returned by Sync. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -641,6 +641,37 @@ func (registry *Registry) destroy(id Int) error {
|
||||
)
|
||||
}
|
||||
|
||||
// Destroy tries to destroy the global object with id.
|
||||
func (registry *Registry) Destroy(id Int) error {
|
||||
if err := registry.destroy(id); err != nil {
|
||||
return err
|
||||
}
|
||||
destroySeq := registry.ctx.currentSeq()
|
||||
|
||||
err := registry.ctx.GetCore().Sync()
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var coreError *CoreError
|
||||
if proxyErrors, ok := err.(ProxyConsumeError); !ok ||
|
||||
len(proxyErrors) != 1 ||
|
||||
!errors.As(proxyErrors[0], &coreError) ||
|
||||
coreError == nil ||
|
||||
coreError.ID != registry.ID ||
|
||||
coreError.Sequence != destroySeq {
|
||||
return err
|
||||
}
|
||||
|
||||
switch syscall.Errno(-coreError.Result) {
|
||||
case syscall.EPERM:
|
||||
return &PermissionError{registry.ID, coreError.Message}
|
||||
|
||||
default:
|
||||
return coreError
|
||||
}
|
||||
}
|
||||
|
||||
// An UnsupportedObjectTypeError is the name of a type not known by the server [Registry].
|
||||
type UnsupportedObjectTypeError string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user