Repository: helm/helm (go)

Issue:
v3.7.0-rc.2: `helm dependency update` no longer works with `file://` repositories
Output of `helm version`: `version.BuildInfo{Version:"v3.7.0-rc.2", GitCommit:"4a7c306aa9dcbdeecf79c7517851921a21b72e56", GitTreeState:"clean", GoVersion:"go1.16.7"}`

Output of `kubectl version`: `Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.1", GitCommit:"632ed300f2c34f6d6d15ca4cef3d3c7073412212", GitTreeState:"clean", BuildDate:"2021-08-19T15:38:26Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.7", GitCommit:"132a687512d7fb058d0f5890f07d4121b3f0a2e2", GitTreeState:"clean", BuildDate:"2021-05-27T23:27:49Z", GoVersion:"go1.15.12", Compiler:"gc", Platform:"linux/amd64"}`

Cloud Provider/Platform (AKS, GKE, Minikube etc.): kind

## Description

Running `helm dependency update` no longer works with `file://` repositories mentioned in Chart.yaml. I no longer see any `*.tgz` files get created in the `charts/` directory. This is a breaking regression that causes `helm install` to throw this error

```
Error: found in Chart.yaml, but missing in charts/ directory: ...
```

## Reproducing the issue

- Setup a `Chart.yaml` with local dependencies 
```yaml
apiVersion: v2
name: my-umbrella-chart
version: 0.1.0
appVersion: 0.1.0
dependencies:
- name: nginx
  version: 0.1.0
  repository: file:///Users/saada/my-charts/nginx
```

- Use helm v3.6.1 and run `helm dependency update` and `/charts` gets populated correctly with the `nginx-0.1.0.tgz` file.
- Delete the tgz file
- Use helm v3.7.0-rc.2 and run `helm dependency update` and `/charts` remains empty. Running the same command with `--debug` mode shows the following logs which indicate that it should have succeeded

```
Repository from local path: file:///Users/saada/my-charts/nginx
Saving 1 charts
Archiving nginx from repo file: file:///Users/saada/my-charts/nginx
Deleting outdated charts
```




Pull request description:
fix tarFromLocalDir saving file dependencies in dest path
Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>

**What this PR does / why we need it**: `tarFromLocalDir` used to save dependencies in the destination folder, `charts`. With the refactor to `downloadAll` in #9889, all dependencies during `helm dependency update` must be saved to `tmpcharts` so that a safe update can occur.

Our test cases verified that `downloadAll` succeeded, but it didn't test whether the dependency was saved to the directory. I added a test to verify the fix.

closes #10112.

**Special notes for your reviewer**:

**If applicable**:
- [x] this PR contains unit tests
- [x] this PR has been tested for backwards compatibility


Patch:
diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go
index b5d7e26b3..cdd9f00dc 100644
--- a/pkg/downloader/manager.go
+++ b/pkg/downloader/manager.go
@@ -302,7 +302,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
 			if m.Debug {
 				fmt.Fprintf(m.Out, "Archiving %s from repo %s\n", dep.Name, dep.Repository)
 			}
-			ver, err := tarFromLocalDir(m.ChartPath, dep.Name, dep.Repository, dep.Version)
+			ver, err := tarFromLocalDir(m.ChartPath, dep.Name, dep.Repository, dep.Version, tmpPath)
 			if err != nil {
 				saveError = err
 				break
@@ -852,10 +852,8 @@ func writeLock(chartpath string, lock *chart.Lock, legacyLockfile bool) error {
 	return ioutil.WriteFile(dest, data, 0644)
 }
 
-// archive a dep chart from local directory and save it into charts/
-func tarFromLocalDir(chartpath, name, repo, version string) (string, error) {
-	destPath := filepath.Join(chartpath, "charts")
-
+// archive a dep chart from local directory and save it into destPath
+func tarFromLocalDir(chartpath, name, repo, version, destPath string) (string, error) {
 	if !strings.HasPrefix(repo, "file://") {
 		return "", errors.Errorf("wrong format: chart %s repository %s", name, repo)
 	}


Test patch:
diff --git a/pkg/downloader/manager_test.go b/pkg/downloader/manager_test.go
index 8b871e66e..4aa0fe11b 100644
--- a/pkg/downloader/manager_test.go
+++ b/pkg/downloader/manager_test.go
@@ -263,6 +263,10 @@ func TestDownloadAll(t *testing.T) {
 	if err := m.downloadAll([]*chart.Dependency{signDep, localDep}); err != nil {
 		t.Error(err)
 	}
+
+	if _, err := os.Stat(filepath.Join(chartPath, "charts", "signtest-0.1.0.tgz")); os.IsNotExist(err) {
+		t.Error(err)
+	}
 }
 
 func TestUpdateBeforeBuild(t *testing.T) {