From 2f836d072d1f9af71294e436758082dc5e42d345 Mon Sep 17 00:00:00 2001 From: maurycy <5383+maurycy@users.noreply.github.com> Date: Mon, 30 Nov 2020 09:55:26 +0100 Subject: [PATCH] use a temporary directory for opening files --- core/space/services/services_fs.go | 2 +- core/space/space_test.go | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/core/space/services/services_fs.go b/core/space/services/services_fs.go index 271d0196..376863d4 100644 --- a/core/space/services/services_fs.go +++ b/core/space/services/services_fs.go @@ -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 diff --git a/core/space/space_test.go b/core/space/space_test.go index 81500186..3f8a3f2f 100644 --- a/core/space/space_test.go +++ b/core/space/space_test.go @@ -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, ) @@ -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)