func (kc *KopiaClient) CreateOrConnectRepo(ctx context.Context, repoDir, bucketName string) error {
	st, err := kc.getStorage(ctx, repoDir, bucketName)
	if err != nil {
		return err
	}

	if iErr := repo.Initialize(ctx, st, &repo.NewRepositoryOptions{}, kc.pw); iErr != nil {
		if !errors.Is(iErr, repo.ErrAlreadyInitialized) {
			return errors.Wrap(iErr, "repo is already initialized")
		}

		log.Println("connecting to existing repository")
	}

	if iErr := repo.Connect(ctx, kc.configPath, st, kc.pw, &repo.ConnectOptions{}); iErr != nil {
		return errors.Wrap(iErr, "error connecting to repository")
	}

	return errors.Wrap(err, "unable to open repository")
}
// CreateOrConnectRepo creates a new Kopia repo or connects to an existing one if possible.
CreateOrConnectRepo creates a new Kopia repo or connects to an existing one if possible.
// CreateOrConnectRepo creates a new Kopia repo or connects to an existing one if possible .
func (kc *KopiaClient) CreateOrConnectRepo(ctx context.Context, repoDir, bucketName string) error {
	st, err := kc.getStorage(ctx, repoDir, bucketName)
	if err != nil {
		return err
	}
	if iErr := repo.Initialize(ctx, st, &repo.NewRepositoryOptions{}, kc.pw); iErr != nil {
		if !errors.Is(iErr, repo.ErrAlreadyInitialized) {
			return errors.Wrap(iErr, "repo is already initialized")
		}
		log.Println("connecting to existing repository")
	}
	if iErr := repo.Connect(ctx, kc.configPath, st, kc.pw, &repo.ConnectOptions{}); iErr != nil {
		return errors.Wrap(iErr, "error connecting to repository")
	}
	return errors.Wrap(err, "unable to open repository")
}
func ( kc * KopiaClient ) CreateOrConnectRepo ( ctx context . Context , repoDir , bucketName string ) error { st , err := kc . getStorage ( ctx , repoDir , bucketName ) if err != nil { return err } if iErr := repo . Initialize ( ctx , st , & repo . NewRepositoryOptions { } , kc . pw ) ; iErr != nil { if ! errors . Is ( iErr , repo . ErrAlreadyInitialized ) { return errors . Wrap ( iErr , " " ) } log . Println ( " " ) } if iErr := repo . Connect ( ctx , kc . configPath , st , kc . pw , & repo . ConnectOptions { } ) ; iErr != nil { return errors . Wrap ( iErr , " " ) } return errors . Wrap ( err , " " ) }
CreateOrConnectRepo creates a new Kopia repo or connects to an existing one if possible.
CreateOrConnectRepo creates a new Kopia repo or connects to an existing one if possible .