Skip to content

Commit

Permalink
fix: make sources.dstFile create parent dirs
Browse files Browse the repository at this point in the history
Clean up all the unit tests that were creating the target dir in
order to pass.

Fixes: Issue #173
  • Loading branch information
nisimond authored and retr0h committed Mar 14, 2024
1 parent 71cff17 commit 462e16b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
1 change: 1 addition & 0 deletions internal/repository/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (r *Copy) CopyFile(

// Open dest file for writing; make it owner-only perms before putting
// anything in it
_ = r.appFs.MkdirAll(r.appFs.Dir(dst), si.Mode())
out, err := r.appFs.Create(dst)
if err != nil {
return err
Expand Down
24 changes: 0 additions & 24 deletions internal/repository/copy_public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ func (suite *CopyPublicTestSuite) TestCopyFileOk() {
srcDir: suite.appFs.Join(suite.cloneDir, "srcDir"),
srcFile: suite.appFs.Join(suite.cloneDir, "srcDir", "1.txt"),
},
{
appFs: suite.appFs,
srcDir: suite.dstDir,
},
}
createFileSpecs(specs)

Expand Down Expand Up @@ -100,10 +96,6 @@ func (suite *CopyPublicTestSuite) TestCopyFileErrorStat() {
srcDir: suite.appFs.Join(suite.cloneDir, "srcDir"),
srcFile: suite.appFs.Join(suite.cloneDir, "srcDir", "1.txt"),
},
{
appFs: suite.appFs,
srcDir: suite.dstDir,
},
}
createFileSpecs(specs)
// Make Stat() calls fail
Expand Down Expand Up @@ -145,10 +137,6 @@ func (suite *CopyPublicTestSuite) TestCopyFileErrorSettingDestfilePerms() {
srcDir: suite.appFs.Join(suite.cloneDir, "srcDir"),
srcFile: suite.appFs.Join(suite.cloneDir, "srcDir", "1.txt"),
},
{
appFs: suite.appFs,
srcDir: suite.dstDir,
},
}
createFileSpecs(specs)
// Make Chmod() calls fail
Expand Down Expand Up @@ -180,10 +168,6 @@ func (suite *CopyPublicTestSuite) TestCopyFileErrorCopy() {
srcDir: suite.appFs.Join(suite.cloneDir, "srcDir"),
srcFile: suite.appFs.Join(suite.cloneDir, "srcDir", "1.txt"),
},
{
appFs: suite.appFs,
srcDir: suite.dstDir,
},
}
createFileSpecs(specs)
assertFile := suite.appFs.Join(suite.dstDir, "1.txt")
Expand All @@ -199,10 +183,6 @@ func (suite *CopyPublicTestSuite) TestCopyFileErrorSync() {
srcDir: suite.appFs.Join(suite.cloneDir, "srcDir"),
srcFile: suite.appFs.Join(suite.cloneDir, "srcDir", "1.txt"),
},
{
appFs: suite.appFs,
srcDir: suite.dstDir,
},
}
createFileSpecs(specs)
// Make Sync() calls fail
Expand All @@ -226,10 +206,6 @@ func (suite *CopyPublicTestSuite) TestCopyFileErrorFinalizingDestfilePerms() {
srcDir: suite.appFs.Join(suite.cloneDir, "srcDir"),
srcFile: suite.appFs.Join(suite.cloneDir, "srcDir", "1.txt"),
},
{
appFs: suite.appFs,
srcDir: suite.dstDir,
},
}
createFileSpecs(specs)
// Make the second Chmod() call fail
Expand Down

0 comments on commit 462e16b

Please sign in to comment.