From 74bd9691c685942798f2761607731697498ceeae Mon Sep 17 00:00:00 2001 From: zeripath Date: Tue, 11 Aug 2020 21:05:34 +0100 Subject: Re-attempt to delete temporary upload if the file is locked by another process (#12447) Replace all calls to os.Remove/os.RemoveAll by retrying util.Remove/util.RemoveAll and remove circular dependencies from util. Fix #12339 Signed-off-by: Andrew Thornton Co-authored-by: silverwind --- integrations/integration_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'integrations/integration_test.go') diff --git a/integrations/integration_test.go b/integrations/integration_test.go index e99264beb8..36e0682099 100644 --- a/integrations/integration_test.go +++ b/integrations/integration_test.go @@ -29,6 +29,7 @@ import ( "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/queue" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/routers" "code.gitea.io/gitea/routers/routes" @@ -98,11 +99,11 @@ func TestMain(m *testing.M) { writerCloser.t = nil - if err = os.RemoveAll(setting.Indexer.IssuePath); err != nil { - fmt.Printf("os.RemoveAll: %v\n", err) + if err = util.RemoveAll(setting.Indexer.IssuePath); err != nil { + fmt.Printf("util.RemoveAll: %v\n", err) os.Exit(1) } - if err = os.RemoveAll(setting.Indexer.RepoPath); err != nil { + if err = util.RemoveAll(setting.Indexer.RepoPath); err != nil { fmt.Printf("Unable to remove repo indexer: %v\n", err) os.Exit(1) } @@ -138,7 +139,7 @@ func initIntegrationTest() { setting.SetCustomPathAndConf("", "", "") setting.NewContext() - os.RemoveAll(models.LocalCopyPath()) + util.RemoveAll(models.LocalCopyPath()) setting.CheckLFSVersion() setting.InitDBConfig() @@ -230,7 +231,7 @@ func prepareTestEnv(t testing.TB, skip ...int) func() { } deferFn := PrintCurrentTest(t, ourSkip) assert.NoError(t, models.LoadFixtures()) - assert.NoError(t, os.RemoveAll(setting.RepoRootPath)) + assert.NoError(t, util.RemoveAll(setting.RepoRootPath)) assert.NoError(t, com.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath)) @@ -473,7 +474,7 @@ func GetCSRF(t testing.TB, session *TestSession, urlStr string) string { func resetFixtures(t *testing.T) { assert.NoError(t, queue.GetManager().FlushAll(context.Background(), -1)) assert.NoError(t, models.LoadFixtures()) - assert.NoError(t, os.RemoveAll(setting.RepoRootPath)) + assert.NoError(t, util.RemoveAll(setting.RepoRootPath)) assert.NoError(t, com.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath)) } -- cgit v1.2.3