mirror of
https://github.com/octoleo/restic.git
synced 2024-11-30 08:44:02 +00:00
migrations: add temporary hack for s3_layout
The migration will be removed after the next restic release anyways. Thus, there's no need for a clean implementation.
This commit is contained in:
parent
34d90aecf9
commit
a1ca5e15c4
@ -256,9 +256,11 @@ func isS3Legacy(b backend.Backend) bool {
|
||||
func (c *Checker) Packs(ctx context.Context, errChan chan<- error) {
|
||||
defer close(errChan)
|
||||
|
||||
if isS3Legacy(c.repo.Backend()) {
|
||||
if r, ok := c.repo.(*repository.Repository); ok {
|
||||
if isS3Legacy(repository.AsS3Backend(r)) {
|
||||
errChan <- ErrLegacyLayout
|
||||
}
|
||||
}
|
||||
|
||||
debug.Log("checking for %d packs", len(c.packs))
|
||||
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"github.com/restic/restic/internal/backend/s3"
|
||||
"github.com/restic/restic/internal/debug"
|
||||
"github.com/restic/restic/internal/errors"
|
||||
"github.com/restic/restic/internal/repository"
|
||||
"github.com/restic/restic/internal/restic"
|
||||
)
|
||||
|
||||
@ -24,7 +25,7 @@ type S3Layout struct{}
|
||||
|
||||
// Check tests whether the migration can be applied.
|
||||
func (m *S3Layout) Check(_ context.Context, repo restic.Repository) (bool, string, error) {
|
||||
be := backend.AsBackend[*s3.Backend](repo.Backend())
|
||||
be := repository.AsS3Backend(repo.(*repository.Repository))
|
||||
if be == nil {
|
||||
debug.Log("backend is not s3")
|
||||
return false, "backend is not s3", nil
|
||||
@ -76,7 +77,7 @@ func (m *S3Layout) moveFiles(ctx context.Context, be *s3.Backend, l layout.Layou
|
||||
|
||||
// Apply runs the migration.
|
||||
func (m *S3Layout) Apply(ctx context.Context, repo restic.Repository) error {
|
||||
be := backend.AsBackend[*s3.Backend](repo.Backend())
|
||||
be := repository.AsS3Backend(repo.(*repository.Repository))
|
||||
if be == nil {
|
||||
debug.Log("backend is not s3")
|
||||
return errors.New("backend is not s3")
|
||||
|
12
internal/repository/s3_backend.go
Normal file
12
internal/repository/s3_backend.go
Normal file
@ -0,0 +1,12 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"github.com/restic/restic/internal/backend"
|
||||
"github.com/restic/restic/internal/backend/s3"
|
||||
)
|
||||
|
||||
// AsS3Backend extracts the S3 backend from a repository
|
||||
// TODO remove me once restic 0.17 was released
|
||||
func AsS3Backend(repo *Repository) *s3.Backend {
|
||||
return backend.AsBackend[*s3.Backend](repo.be)
|
||||
}
|
Loading…
Reference in New Issue
Block a user