Repository: kopia/kopia
Pull request #3607 (2024-02-02 00:30:58)

refactor(cli): miscellaneous code simplifications
- Simplification in `onTerminate` callback function for snapshot migrate command.
- Quote strings, via `%q`, in assertion failure message for clarity.

Proposed by @aaron-kasten 

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/kopia/kopia/pull/3607?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia) Report
Attention: `8 lines` in your changes are missing coverage. Please review.
> Comparison is base [(`37da48b`)](https://app.codecov.io/gh/kopia/kopia/commit/37da48b641543763dcb4f4f5885b98f8deeaacc9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia) 75.85% compared to head [(`05ca02a`)](https://app.codecov.io/gh/kopia/kopia/pull/3607?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia) 75.85%.

| [Files](https://app.codecov.io/gh/kopia/kopia/pull/3607?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia) | Patch % | Lines |
|---|---|---|
| [cli/command\_snapshot\_migrate.go](https://app.codecov.io/gh/kopia/kopia/pull/3607?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia#diff-Y2xpL2NvbW1hbmRfc25hcHNob3RfbWlncmF0ZS5nbw==) | 0.00% | [8 Missing :warning: ](https://app.codecov.io/gh/kopia/kopia/pull/3607?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia) |

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master    #3607   +/-   ##
=======================================
  Coverage   75.85%   75.85%           
=======================================
  Files         465      465           
  Lines       37182    37185    +3     
=======================================
+ Hits        28204    28207    +3     
+ Misses       7051     7049    -2     
- Partials     1927     1929    +2     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/kopia/kopia/pull/3607?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia).


Patch:
diff --git a/cli/command_snapshot_migrate.go b/cli/command_snapshot_migrate.go
index 724ff7b3..4a371f83 100644
--- a/cli/command_snapshot_migrate.go
+++ b/cli/command_snapshot_migrate.go
@@ -72,12 +72,15 @@ func (c *commandSnapshotMigrate) run(ctx context.Context, destRepo repo.Reposito
 		mu.Lock()
 		defer mu.Unlock()
 
-		if !canceled {
-			canceled = true
-			for s, u := range activeUploaders {
-				log(ctx).Infof("canceling active uploader for %v", s)
-				u.Cancel()
-			}
+		if canceled {
+			return
+		}
+
+		canceled = true
+
+		for s, u := range activeUploaders {
+			log(ctx).Infof("canceling active uploader for %v", s)
+			u.Cancel()
 		}
 	})
 
diff --git a/go.mod b/go.mod
index 5422ef31..e3c83fba 100644
--- a/go.mod
+++ b/go.mod
@@ -29,7 +29,7 @@ require (
 	github.com/hashicorp/cronexpr v1.1.2
 	github.com/klauspost/compress v1.17.6
 	github.com/klauspost/pgzip v1.2.6
-	github.com/klauspost/reedsolomon v1.12.0
+	github.com/klauspost/reedsolomon v1.12.1
 	github.com/kopia/htmluibuild v0.0.1-0.20231019063300-75c2a788c7d0
 	github.com/kylelemons/godebug v1.1.0
 	github.com/mattn/go-colorable v0.1.13
diff --git a/go.sum b/go.sum
index 3699c3dc..fa7e7393 100644
--- a/go.sum
+++ b/go.sum
@@ -197,8 +197,8 @@ github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/4
 github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
 github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU=
 github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
-github.com/klauspost/reedsolomon v1.12.0 h1:I5FEp3xSwVCcEh3F5A7dofEfhXdF/bWhQWPH+XwBFno=
-github.com/klauspost/reedsolomon v1.12.0/go.mod h1:EPLZJeh4l27pUGC3aXOjheaoh1I9yut7xTURiW3LQ9Y=
+github.com/klauspost/reedsolomon v1.12.1 h1:NhWgum1efX1x58daOBGCFWcxtEhOhXKKl1HAPQUp03Q=
+github.com/klauspost/reedsolomon v1.12.1/go.mod h1:nEi5Kjb6QqtbofI6s+cbG/j1da11c96IBYBSnVGtuBs=
 github.com/kopia/htmluibuild v0.0.1-0.20231019063300-75c2a788c7d0 h1:TvupyyfbUZzsO4DQJpQhKZnUa61xERcJ+ejCbHWG2NY=
 github.com/kopia/htmluibuild v0.0.1-0.20231019063300-75c2a788c7d0/go.mod h1:cSImbrlwvv2phvj5RfScL2v08ghX6xli0PcK6f+t8S0=
 github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
diff --git a/site/content/docs/Repository Server/_index.md b/site/content/docs/Repository Server/_index.md
index 65ca5d26..35509e91 100644
--- a/site/content/docs/Repository Server/_index.md
+++ b/site/content/docs/Repository Server/_index.md
@@ -40,20 +40,6 @@ Other commands are also available:
 * `kopia server user set` - changes password
 * `kopia server user delete` - deletes user account
 
->__Prior to Kopia v0.8__, the user list must be put in a text file formatted using the [htpasswd](https://httpd.apache.org/docs/2.4/programs/htpasswd.html) utility from Apache. This method is still supported in v0.8, but it's recommended to use `kopia server user` to manage users instead.
-> To create password file for two users: 
-> ```shell
-> $ htpasswd -c password.txt user1@host1
-> New password: 
-> Re-type new password: 
-> Adding password for user user1@host1
-> 
-> $ htpasswd password.txt user2@host1
-> New password: 
-> Re-type new password: 
-> Adding password for user user2@host1
-> ```
-
 ### Auto-Generated TLS Certificate
 
 To start repository server with auto-generated TLS certificate for the first time:
@@ -76,8 +62,6 @@ SERVER CERT SHA256: 48537cce585fed39fb26c639eb8ef38143592ba4b4e7677a84a31916398d
 
 Note that when starting the server again the `--tls-generate-cert` must be omitted, otherwise the server will fail to start.
 
->__Prior to Kopia v0.8,__ the command line for `kopia server start` also needs `--htpasswd-file ~/password.txt`
-
 ### Custom TLS Certificates
 
 If a user has obtained custom certificate (for example from LetsEncrypt or another CA), using it is simply a matter of providing PEM-formatted certificate and key files on server startup.
@@ -114,8 +98,7 @@ $ kopia repo connect server --url=http://11.222.111.222:51515 --override-usernam
 
 Kopia server will check permissions when users try to access contents and manifests based on rules we call ACLs (access control list).
 
->__Prior to Kopia v0.8,__ the rules were non-configurable and each user could only read and write their own
-snapshot manifests. Starting in Kopia v0.8 the ACLs can be controlled by using `kopia server acl` commands. 
+Starting in Kopia v0.8, the ACLs can be controlled by using `kopia server acl` commands. 
 
 If no ACLs are explicitly defined, Kopia will use a set of built-in access control rules, which grants all authenticated users identified by `username@hostname` ability to:
 
@@ -269,6 +252,33 @@ or simply:
 $ killall -SIGHUP kopia
 ```
 
+## Kopia v0.8 usage notes
+
+### Configuring Allowed Users
+
+Prior to Kopia v0.8, the user list must be put in a text file formatted using the [htpasswd](https://httpd.apache.org/docs/2.4/programs/htpasswd.html) utility from Apache. This method is still supported in v0.8, but it's recommended to use `kopia server user` to manage users instead.
+To create password file for two users: 
+```shell
+$ htpasswd -c password.txt user1@host1
+New password: 
+Re-type new password: 
+Adding password for user user1@host1
+
+$ htpasswd password.txt user2@host1
+New password: 
+Re-type new password: 
+Adding password for user user2@host1
+```
+
+### Auto-Generated TLS Certificate
+
+Prior to Kopia v0.8, the command line for `kopia server start` also needs `--htpasswd-file ~/password.txt`
+
+### Server Access Control (ACL)
+
+Prior to Kopia v0.8, the rules were non-configurable and each user could only read and write their own
+snapshot manifests.
+
 ## Kopia behind a reverse proxy
 
 Kopia server can be run behind a reverse proxy. Here a working example for nginx.


Test patch:
diff --git a/internal/logfile/logfile_test.go b/internal/logfile/logfile_test.go
index 8cf6c371..56547ac5 100644
--- a/internal/logfile/logfile_test.go
+++ b/internal/logfile/logfile_test.go
@@ -207,7 +207,7 @@ func verifyFileLogFormat(t *testing.T, fname string, re *regexp.Regexp) {
 	s := bufio.NewScanner(f)
 
 	for s.Scan() {
-		require.True(t, re.MatchString(s.Text()), "log line does not match the format: %v (re %v)", s.Text(), re.String())
+		require.True(t, re.MatchString(s.Text()), "log line does not match the format: %q (re %q)", s.Text(), re.String())
 	}
 }