Repository: kopia/kopia
Pull request #2678 (2023-01-04 23:04:16)

build(deps): bump golang.org/x/term from 0.2.0 to 0.4.0
Bumps [golang.org/x/term](https://github.com/golang/term) from 0.2.0 to 0.4.0.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/golang/term/commit/1efcd90d861e239a7719db7012b81621e6f7d297"><code>1efcd90</code></a> go.mod: update golang.org/x dependencies</li>
<li><a href="https://github.com/golang/term/commit/97ca0e3821bf3a3cf6ea2441ece139e524802385"><code>97ca0e3</code></a> go.mod: update golang.org/x dependencies</li>
<li>See full diff in <a href="https://github.com/golang/term/compare/v0.2.0...v0.4.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=golang.org/x/term&package-manager=go_modules&previous-version=0.2.0&new-version=0.4.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
Dependabot will merge this PR once CI passes on it, as requested by @kopia-builder.

[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

codecov[bot]: # [Codecov](https://codecov.io/gh/kopia/kopia/pull/2678?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia) Report
Base: **74.99**% // Head: **74.98**% // Decreases project coverage by **`-0.00%`** :warning:
> Coverage data is based on head [(`ffb2a20`)](https://codecov.io/gh/kopia/kopia/pull/2678?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia) compared to base [(`ba938cf`)](https://codecov.io/gh/kopia/kopia/commit/ba938cf58cc8db26eb373f6ddff5fc0e9c07af15?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia).
> Patch has no changes to coverable lines.

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


```diff
@@            Coverage Diff             @@
##           master    #2678      +/-   ##
==========================================
- Coverage   74.99%   74.98%   -0.01%     
==========================================
  Files         457      457              
  Lines       35811    35811              
==========================================
- Hits        26857    26854       -3     
- Misses       7056     7062       +6     
+ Partials     1898     1895       -3     
```


| [Impacted Files](https://codecov.io/gh/kopia/kopia/pull/2678?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia) | Coverage Δ | |
|---|---|---|
| [snapshot/snapshotfs/repofs.go](https://codecov.io/gh/kopia/kopia/pull/2678?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia#diff-c25hcHNob3Qvc25hcHNob3Rmcy9yZXBvZnMuZ28=) | `79.29% <0.00%> (-1.52%)` | :arrow_down: |
| [cli/command\_index\_recover.go](https://codecov.io/gh/kopia/kopia/pull/2678?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia#diff-Y2xpL2NvbW1hbmRfaW5kZXhfcmVjb3Zlci5nbw==) | `65.00% <0.00%> (-1.43%)` | :arrow_down: |
| [internal/server/source\_manager.go](https://codecov.io/gh/kopia/kopia/pull/2678?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia#diff-aW50ZXJuYWwvc2VydmVyL3NvdXJjZV9tYW5hZ2VyLmdv) | `80.66% <0.00%> (-0.77%)` | :arrow_down: |
| [snapshot/snapshotfs/upload.go](https://codecov.io/gh/kopia/kopia/pull/2678?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia#diff-c25hcHNob3Qvc25hcHNob3Rmcy91cGxvYWQuZ28=) | `85.28% <0.00%> (-0.12%)` | :arrow_down: |
| [repo/open.go](https://codecov.io/gh/kopia/kopia/pull/2678?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia#diff-cmVwby9vcGVuLmdv) | `79.33% <0.00%> (+1.00%)` | :arrow_up: |
| [internal/dirutil/mksubdirall.go](https://codecov.io/gh/kopia/kopia/pull/2678?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia#diff-aW50ZXJuYWwvZGlydXRpbC9ta3N1YmRpcmFsbC5nbw==) | `100.00% <0.00%> (+7.89%)` | :arrow_up: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/kopia/kopia/pull/2678?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kopia).

jkowalski: @dependabot rebase

Patch:
diff --git a/app/package-lock.json b/app/package-lock.json
index fdaf5e1b..082b97ae 100644
--- a/app/package-lock.json
+++ b/app/package-lock.json
@@ -15,7 +15,7 @@
         "electron-log": "^4.4.8",
         "electron-updater": "^5.2.1",
         "minimist": "^1.2.7",
-        "uuid": "^8.3.2"
+        "uuid": "^9.0.0"
       },
       "devDependencies": {
         "@playwright/test": "^1.26.1",
@@ -3598,9 +3598,9 @@
       "dev": true
     },
     "node_modules/uuid": {
-      "version": "8.3.2",
-      "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
-      "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
+      "version": "9.0.0",
+      "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz",
+      "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==",
       "bin": {
         "uuid": "dist/bin/uuid"
       }
@@ -6544,9 +6544,9 @@
       "dev": true
     },
     "uuid": {
-      "version": "8.3.2",
-      "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
-      "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
+      "version": "9.0.0",
+      "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz",
+      "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg=="
     },
     "verror": {
       "version": "1.10.1",
diff --git a/app/package.json b/app/package.json
index 6eab894b..8d995627 100644
--- a/app/package.json
+++ b/app/package.json
@@ -9,7 +9,7 @@
     "electron-log": "^4.4.8",
     "electron-updater": "^5.2.1",
     "minimist": "^1.2.7",
-    "uuid": "^8.3.2"
+    "uuid": "^9.0.0"
   },
   "author": {
     "email": "kopia-pmc@googlegroups.com",
diff --git a/cli/command_snapshot_create.go b/cli/command_snapshot_create.go
index a564dd70..de3f9ad9 100644
--- a/cli/command_snapshot_create.go
+++ b/cli/command_snapshot_create.go
@@ -3,6 +3,7 @@
 import (
 	"context"
 	"fmt"
+	"io"
 	"path/filepath"
 	"strings"
 	"time"
@@ -273,7 +274,7 @@ func (c *commandSnapshotCreate) snapshotSingleSource(ctx context.Context, rep re
 		// stdin source will be snapshotted using a virtual static root directory with a single streaming file entry
 		// Create a new static directory with the given name and add a streaming file entry with os.Stdin reader
 		fsEntry = virtualfs.NewStaticDirectory(sourceInfo.Path, []fs.Entry{
-			virtualfs.StreamingFileFromReader(c.snapshotCreateStdinFileName, c.svc.stdin()),
+			virtualfs.StreamingFileFromReader(c.snapshotCreateStdinFileName, io.NopCloser(c.svc.stdin())),
 		})
 		setManual = true
 	} else {
diff --git a/fs/entry.go b/fs/entry.go
index 2fb5a7ff..26f4dd3b 100644
--- a/fs/entry.go
+++ b/fs/entry.go
@@ -53,7 +53,7 @@ type File interface {
 // StreamingFile represents an entry that is a stream.
 type StreamingFile interface {
 	Entry
-	GetReader(ctx context.Context) (io.Reader, error)
+	GetReader(ctx context.Context) (io.ReadCloser, error)
 }
 
 // Directory represents contents of a directory.
diff --git a/fs/virtualfs/virtualfs.go b/fs/virtualfs/virtualfs.go
index c11e4cc6..059d9161 100644
--- a/fs/virtualfs/virtualfs.go
+++ b/fs/virtualfs/virtualfs.go
@@ -167,7 +167,7 @@ func NewStreamingDirectory(
 // virtualFile is an implementation of fs.StreamingFile with an io.Reader.
 type virtualFile struct {
 	virtualEntry
-	reader io.Reader
+	reader io.ReadCloser
 }
 
 var errReaderAlreadyUsed = errors.New("cannot use streaming file reader more than once")
@@ -175,7 +175,7 @@ type virtualFile struct {
 // GetReader returns the streaming file's reader.
 // Note: Caller of this function has to ensure concurrency safety.
 // The file's reader is set to nil after the first call.
-func (vf *virtualFile) GetReader(ctx context.Context) (io.Reader, error) {
+func (vf *virtualFile) GetReader(ctx context.Context) (io.ReadCloser, error) {
 	if vf.reader == nil {
 		return nil, errReaderAlreadyUsed
 	}
@@ -188,12 +188,12 @@ func (vf *virtualFile) GetReader(ctx context.Context) (io.Reader, error) {
 }
 
 // StreamingFileFromReader returns a streaming file with given name and reader.
-func StreamingFileFromReader(name string, reader io.Reader) fs.StreamingFile {
+func StreamingFileFromReader(name string, reader io.ReadCloser) fs.StreamingFile {
 	return StreamingFileWithModTimeFromReader(name, clock.Now(), reader)
 }
 
 // StreamingFileWithModTimeFromReader returns a streaming file with given name, modified time, and reader.
-func StreamingFileWithModTimeFromReader(name string, t time.Time, reader io.Reader) fs.StreamingFile {
+func StreamingFileWithModTimeFromReader(name string, t time.Time, reader io.ReadCloser) fs.StreamingFile {
 	return &virtualFile{
 		virtualEntry: virtualEntry{
 			name:    name,
diff --git a/go.mod b/go.mod
index 3f6e6da0..a71250d1 100644
--- a/go.mod
+++ b/go.mod
@@ -54,8 +54,8 @@ require (
 	golang.org/x/net v0.2.0
 	golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783
 	golang.org/x/sync v0.1.0
-	golang.org/x/sys v0.3.0
-	golang.org/x/term v0.2.0
+	golang.org/x/sys v0.4.0
+	golang.org/x/term v0.4.0
 	golang.org/x/text v0.5.0
 	google.golang.org/api v0.104.0
 	google.golang.org/grpc v1.51.0
diff --git a/go.sum b/go.sum
index a8f34f51..c857ff80 100644
--- a/go.sum
+++ b/go.sum
@@ -606,13 +606,13 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
-golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
+golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM=
-golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
+golang.org/x/term v0.4.0 h1:O7UWfv5+A2qiuulQk30kVinPoMtoIPeVaKLEgLpVkvg=
+golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
diff --git a/snapshot/snapshotfs/upload.go b/snapshot/snapshotfs/upload.go
index 6e08d649..d615eb00 100644
--- a/snapshot/snapshotfs/upload.go
+++ b/snapshot/snapshotfs/upload.go
@@ -342,6 +342,8 @@ func (u *Uploader) uploadStreamingFileInternal(ctx context.Context, relativePath
 		return nil, errors.Wrap(err, "unable to get streaming file reader")
 	}
 
+	defer reader.Close() //nolint:errcheck
+
 	var streamSize int64
 
 	u.Progress.HashingFile(relativePath)


Test patch:
diff --git a/fs/virtualfs/virtualfs_test.go b/fs/virtualfs/virtualfs_test.go
index 041030de..5ed2100b 100644
--- a/fs/virtualfs/virtualfs_test.go
+++ b/fs/virtualfs/virtualfs_test.go
@@ -4,6 +4,7 @@
 	"bytes"
 	"context"
 	"errors"
+	"io"
 	"os"
 	"reflect"
 	"testing"
@@ -76,9 +77,9 @@ func TestStreamingFile(t *testing.T) {
 
 func TestStreamingFileModTime(t *testing.T) {
 	data := []byte("data")
-	f1 := StreamingFileFromReader("f1", bytes.NewReader(data))
+	f1 := StreamingFileFromReader("f1", io.NopCloser(bytes.NewReader(data)))
 	mt := time.Date(2021, 1, 2, 3, 4, 5, 0, time.UTC)
-	f2 := StreamingFileWithModTimeFromReader("f2", mt, bytes.NewReader(data))
+	f2 := StreamingFileWithModTimeFromReader("f2", mt, io.NopCloser(bytes.NewReader(data)))
 
 	assert.True(t, f1.ModTime().After(f2.ModTime()))
 }
@@ -130,7 +131,7 @@ func TestStreamingFileGetReader(t *testing.T) {
 func TestStreamingDirectory(t *testing.T) {
 	// Create a temporary file with test data
 	content := []byte("Temporary file content")
-	r := bytes.NewReader(content)
+	r := io.NopCloser(bytes.NewReader(content))
 
 	f := StreamingFileFromReader(testFileName, r)
 
@@ -167,7 +168,7 @@ func(
 func TestStreamingDirectory_MultipleIterationsFails(t *testing.T) {
 	// Create a temporary file with test data
 	content := []byte("Temporary file content")
-	r := bytes.NewReader(content)
+	r := io.NopCloser(bytes.NewReader(content))
 
 	f := StreamingFileFromReader(testFileName, r)
 
@@ -195,7 +196,7 @@ func(
 func TestStreamingDirectory_ReturnsCallbackError(t *testing.T) {
 	// Create a temporary file with test data
 	content := []byte("Temporary file content")
-	r := bytes.NewReader(content)
+	r := io.NopCloser(bytes.NewReader(content))
 
 	f := StreamingFileFromReader(testFileName, r)
 
diff --git a/snapshot/snapshotfs/upload_test.go b/snapshot/snapshotfs/upload_test.go
index 16fb722e..fbb026c8 100644
--- a/snapshot/snapshotfs/upload_test.go
+++ b/snapshot/snapshotfs/upload_test.go
@@ -886,7 +886,7 @@ func TestUpload_VirtualDirectoryWithStreamingFileWithModTime(t *testing.T) {
 		{
 			desc: "CurrentTime",
 			getFile: func() fs.StreamingFile {
-				return virtualfs.StreamingFileFromReader("a", bytes.NewReader(content))
+				return virtualfs.StreamingFileFromReader("a", io.NopCloser(bytes.NewReader(content)))
 			},
 			cachedFiles:   0,
 			uploadedFiles: 1,
@@ -894,7 +894,7 @@ func TestUpload_VirtualDirectoryWithStreamingFileWithModTime(t *testing.T) {
 		{
 			desc: "FixedTime",
 			getFile: func() fs.StreamingFile {
-				return virtualfs.StreamingFileWithModTimeFromReader("a", mt, bytes.NewReader(content))
+				return virtualfs.StreamingFileWithModTimeFromReader("a", mt, io.NopCloser(bytes.NewReader(content)))
 			},
 			cachedFiles:   1,
 			uploadedFiles: 0,
diff --git a/tests/tools/kopiaclient/kopiaclient.go b/tests/tools/kopiaclient/kopiaclient.go
index 359759ed..2cec7982 100644
--- a/tests/tools/kopiaclient/kopiaclient.go
+++ b/tests/tools/kopiaclient/kopiaclient.go
@@ -210,7 +210,7 @@ func (kc *KopiaClient) getStorage(ctx context.Context, repoDir, bucketName strin
 // reads its contents from `val`.
 func (kc *KopiaClient) getSourceForKeyVal(key string, val []byte) fs.Entry {
 	return virtualfs.NewStaticDirectory(key, []fs.Entry{
-		virtualfs.StreamingFileFromReader(dataFileName, bytes.NewReader(val)),
+		virtualfs.StreamingFileFromReader(dataFileName, io.NopCloser(bytes.NewReader(val))),
 	})
 }