diff --git a/src/internal/kopia/conn.go b/src/internal/kopia/conn.go index 5e0d3a14d..40929987d 100644 --- a/src/internal/kopia/conn.go +++ b/src/internal/kopia/conn.go @@ -10,6 +10,7 @@ import ( "github.com/kopia/kopia/repo/blob" "github.com/kopia/kopia/repo/compression" "github.com/kopia/kopia/repo/content" + "github.com/kopia/kopia/repo/manifest" "github.com/kopia/kopia/snapshot" "github.com/kopia/kopia/snapshot/policy" "github.com/pkg/errors" @@ -59,6 +60,8 @@ func IsRepoAlreadyExistsError(e error) bool { return errors.As(e, &erae) } +var _ snapshotManager = &conn{} + type conn struct { storage storage.Storage repo.Repository @@ -379,3 +382,10 @@ func checkCompressor(compressor compression.Name) error { return errors.Errorf("unknown compressor type %s", compressor) } + +func (w *conn) LoadSnapshots( + ctx context.Context, + ids []manifest.ID, +) ([]*snapshot.Manifest, error) { + return snapshot.LoadSnapshots(ctx, w.Repository, ids) +} diff --git a/src/internal/kopia/snapshot_manager.go b/src/internal/kopia/snapshot_manager.go index 12f768fbd..23148c3b5 100644 --- a/src/internal/kopia/snapshot_manager.go +++ b/src/internal/kopia/snapshot_manager.go @@ -187,9 +187,6 @@ func fetchPrevManifests( // incomplete. An incomplete manifest may be returned if it is newer than the // newest complete manifest for the tuple. Manifests are deduped such that if // multiple tuples match the same manifest it will only be returned once. -// -// TODO(ashmrtn): Use to get previous manifests so backup can find previously -// uploaded versions of a file. func fetchPrevSnapshotManifests( ctx context.Context, sm snapshotManager, diff --git a/src/internal/kopia/wrapper.go b/src/internal/kopia/wrapper.go index 3420cc4e0..e91cb11a3 100644 --- a/src/internal/kopia/wrapper.go +++ b/src/internal/kopia/wrapper.go @@ -530,6 +530,8 @@ func (w Wrapper) makeSnapshotWithRoot( ) (*BackupStats, error) { var man *snapshot.Manifest + prevSnaps := fetchPrevSnapshotManifests(ctx, w.c, oc) + bc := &stats.ByteCounter{} err := repo.WriteSession( @@ -569,7 +571,7 @@ func (w Wrapper) makeSnapshotWithRoot( progress.UploadProgress = u.Progress u.Progress = progress - man, err = u.Upload(innerCtx, root, policyTree, si) + man, err = u.Upload(innerCtx, root, policyTree, si, prevSnaps...) if err != nil { err = errors.Wrap(err, "uploading data") logger.Ctx(innerCtx).Errorw("kopia backup", err)