Skip to content

Commit

Permalink
use a temporary directory for opening files
Browse files Browse the repository at this point in the history
  • Loading branch information
maurycy authored Nov 30, 2020
1 parent e3fd931 commit 2f836d0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/space/services/services_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func (s *Space) TruncateData(ctx context.Context) error {

func (s *Space) openFileOnFs(ctx context.Context, path string, b textile.Bucket, isRemote bool, dbID, cid string) (string, error) {
// write file copy to temp folder
tmpFile, err := s.createTempFileForPath(ctx, path, false)
tmpFile, err := s.createTempFileForPath(ctx, path, true)
if err != nil {
log.Error("cannot create temp file while executing OpenFile", err)
return "", err
Expand Down
10 changes: 1 addition & 9 deletions core/space/space_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,6 @@ func TestService_OpenFile(t *testing.T) {
testFileName := "file.txt"

// setup mocks
cfg.On("GetInt", mock.Anything, mock.Anything).Return(
-1,
)

cfg.On("GetString", mock.Anything, mock.Anything).Return(
"",
)

mockEnv.On("WorkingFolder").Return(
getDir().dir,
)
Expand Down Expand Up @@ -392,7 +384,7 @@ func TestService_OpenFile(t *testing.T) {
assert.Nil(t, err)
assert.NotEmpty(t, res)
assert.FileExists(t, res.Location)
assert.Contains(t, res.Location, getDir().dir)
assert.Contains(t, res.Location, os.TempDir())
assert.True(t, strings.HasSuffix(res.Location, testFileName))
// assert mocks
cfg.AssertExpectations(t)
Expand Down

0 comments on commit 2f836d0

Please sign in to comment.