diff --git a/Makefile b/Makefile index c2f151784..2be8697b1 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,10 @@ COVERAGE_PACKAGES=./repo/...,./fs/...,./snapshot/... -all: install install-examples test lint vet integration-tests +all: install test lint vet integration-tests install: go install github.com/kopia/kopia -install-examples: - go install github.com/kopia/kopia/examples/repository - install-race: go install -race github.com/kopia/kopia diff --git a/cli/command_repository_migrate.go b/cli/command_repository_migrate.go index 7e2800972..ad5a5edc7 100644 --- a/cli/command_repository_migrate.go +++ b/cli/command_repository_migrate.go @@ -4,7 +4,6 @@ "context" "fmt" - "github.com/kopia/kopia/internal/upload" "github.com/kopia/kopia/snapshot" "github.com/kopia/kopia/snapshot/snapshotfs" "github.com/kopia/repo" @@ -22,7 +21,7 @@ ) func runMigrateCommand(ctx context.Context, destRepo *repo.Repository) error { - uploader := upload.NewUploader(destRepo) + uploader := snapshotfs.NewUploader(destRepo) uploader.Progress = cliProgress uploader.IgnoreFileErrors = *migrateIgnoreErrors onCtrlC(uploader.Cancel) @@ -65,7 +64,7 @@ func runMigrateCommand(ctx context.Context, destRepo *repo.Repository) error { return nil } -func migrateSingleSource(ctx context.Context, uploader *upload.Uploader, sourceRepo, destRepo *repo.Repository, s snapshot.SourceInfo) error { +func migrateSingleSource(ctx context.Context, uploader *snapshotfs.Uploader, sourceRepo, destRepo *repo.Repository, s snapshot.SourceInfo) error { log.Debugf("migrating source %v", s) manifests, err := snapshot.ListSnapshotManifests(ctx, sourceRepo, &s) diff --git a/cli/command_snapshot_create.go b/cli/command_snapshot_create.go index 57cc4111e..b771b7298 100644 --- a/cli/command_snapshot_create.go +++ b/cli/command_snapshot_create.go @@ -11,9 +11,9 @@ "strings" "time" - "github.com/kopia/kopia/internal/upload" "github.com/kopia/kopia/snapshot" "github.com/kopia/kopia/snapshot/policy" + "github.com/kopia/kopia/snapshot/snapshotfs" "github.com/kopia/repo" ) @@ -47,7 +47,7 @@ func runBackupCommand(ctx context.Context, rep *repo.Repository) error { return errors.New("no backup sources") } - u := upload.NewUploader(rep) + u := snapshotfs.NewUploader(rep) u.MaxUploadBytes = *snapshotCreateCheckpointUploadLimitMB * 1024 * 1024 u.ForceHashPercentage = *snapshotCreateForceHash u.HashCacheMinAge = *snapshotCreateHashCacheMinAge @@ -83,7 +83,7 @@ func runBackupCommand(ctx context.Context, rep *repo.Repository) error { return fmt.Errorf("encountered %v errors:\n%v", len(finalErrors), strings.Join(finalErrors, "\n")) } -func snapshotSingleSource(ctx context.Context, rep *repo.Repository, u *upload.Uploader, sourceInfo snapshot.SourceInfo) error { +func snapshotSingleSource(ctx context.Context, rep *repo.Repository, u *snapshotfs.Uploader, sourceInfo snapshot.SourceInfo) error { t0 := time.Now() rep.Blocks.ResetStats() diff --git a/internal/server/source_manager.go b/internal/server/source_manager.go index 4c230139a..f3a2f8229 100644 --- a/internal/server/source_manager.go +++ b/internal/server/source_manager.go @@ -7,9 +7,9 @@ "github.com/kopia/kopia/fs/localfs" "github.com/kopia/kopia/internal/serverapi" - "github.com/kopia/kopia/internal/upload" "github.com/kopia/kopia/snapshot" "github.com/kopia/kopia/snapshot/policy" + "github.com/kopia/kopia/snapshot/snapshotfs" ) // sourceManager manages the state machine of each source @@ -164,7 +164,7 @@ func (s *sourceManager) snapshot(ctx context.Context) { log.Errorf("unable to create local filesystem: %v", err) return } - u := upload.NewUploader(s.server.rep) + u := snapshotfs.NewUploader(s.server.rep) polGetter, err := policy.FilesPolicyGetter(ctx, s.server.rep, s.src) if err != nil { log.Errorf("unable to create policy getter: %v", err) diff --git a/internal/upload/upload.go b/snapshot/snapshotfs/upload.go similarity index 99% rename from internal/upload/upload.go rename to snapshot/snapshotfs/upload.go index 866b53a08..1568043cc 100644 --- a/internal/upload/upload.go +++ b/snapshot/snapshotfs/upload.go @@ -1,5 +1,4 @@ -// Package upload manages uploading snapshots to the repository. -package upload +package snapshotfs import ( "bytes" @@ -20,9 +19,9 @@ "github.com/kopia/kopia/internal/dir" "github.com/kopia/kopia/internal/hashcache" "github.com/kopia/kopia/internal/kopialogging" + "github.com/kopia/kopia/snapshot" "github.com/kopia/repo" "github.com/kopia/repo/object" - "github.com/kopia/kopia/snapshot" ) var log = kopialogging.Logger("kopia/upload") @@ -46,7 +45,7 @@ func metadataHash(e *fs.EntryMetadata) uint64 { // Uploader supports efficient uploading files and directories to repository. type Uploader struct { - Progress Progress + Progress UploadProgress FilesPolicy ignorefs.FilesPolicyGetter diff --git a/internal/upload/upload_progress.go b/snapshot/snapshotfs/upload_progress.go similarity index 65% rename from internal/upload/upload_progress.go rename to snapshot/snapshotfs/upload_progress.go index a7d2b1030..fe57a3be1 100644 --- a/internal/upload/upload_progress.go +++ b/snapshot/snapshotfs/upload_progress.go @@ -1,9 +1,9 @@ -package upload +package snapshotfs import "github.com/kopia/kopia/snapshot" -// Progress is invoked by by uploader to report status of file and directory uploads. -type Progress interface { +// UploadProgress is invoked by by uploader to report status of file and directory uploads. +type UploadProgress interface { Progress(path string, numFiles int, pathCompleted, pathTotal int64, stats *snapshot.Stats) UploadFinished() } @@ -17,4 +17,4 @@ func (p *nullUploadProgress) Progress(path string, numFiles int, pathCompleted, func (p *nullUploadProgress) UploadFinished() { } -var _ Progress = (*nullUploadProgress)(nil) +var _ UploadProgress = (*nullUploadProgress)(nil) diff --git a/internal/upload/upload_test.go b/snapshot/snapshotfs/upload_test.go similarity index 99% rename from internal/upload/upload_test.go rename to snapshot/snapshotfs/upload_test.go index 5c913e252..265b5a0bb 100644 --- a/internal/upload/upload_test.go +++ b/snapshot/snapshotfs/upload_test.go @@ -1,4 +1,4 @@ -package upload +package snapshotfs import ( "context"