Add initial triplestore rebuild functionality
This commit is contained in:
parent
8a1319df16
commit
674b9d8d07
11 changed files with 252 additions and 56 deletions
28
internal/dis/component/triplestore/restore.go
Normal file
28
internal/dis/component/triplestore/restore.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package triplestore
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var errTSRestoreWrongStatusCode = errors.New("Triplestore.Restore: Wrong status code")
|
||||
|
||||
// RestoreDB snapshots the provided repository into dst
|
||||
func (ts Triplestore) RestoreDB(ctx context.Context, repo string, reader io.Reader) error {
|
||||
// submit the form
|
||||
res, err := ts.DoRestWithReader(ctx, 0, http.MethodPut, "/repositories/"+repo+"/statements", &RequestHeaders{ContentType: nquadsContentType}, reader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
if res.StatusCode != http.StatusNoContent {
|
||||
message, _ := io.ReadAll(res.Body)
|
||||
return fmt.Errorf("%w: %s", errTSRestoreWrongStatusCode, message)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue