mirror of
https://github.com/go-gitea/gitea.git
synced 2025-04-08 17:05:45 +02:00
use global configuration temp directories
This commit is contained in:
parent
fc25971f57
commit
b362ffaa0c
@ -18,6 +18,7 @@ import (
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/proxy"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
)
|
||||
|
||||
@ -279,11 +280,11 @@ func GetDivergingCommits(ctx context.Context, repoPath, baseBranch, targetBranch
|
||||
|
||||
// CreateBundle create bundle content to the target path
|
||||
func (repo *Repository) CreateBundle(ctx context.Context, commit string, out io.Writer) error {
|
||||
tmp, err := os.MkdirTemp(os.TempDir(), "gitea-bundle")
|
||||
tmp, err := os.MkdirTemp(setting.TempDir(), "gitea-bundle")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.RemoveAll(tmp)
|
||||
defer util.RemoveAll(tmp)
|
||||
|
||||
env := append(os.Environ(), "GIT_OBJECT_DIRECTORY="+filepath.Join(repo.Path, "objects"))
|
||||
_, _, err = NewCommand(ctx, "init", "--bare").RunStdString(&RunOpts{Dir: tmp, Env: env})
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
)
|
||||
|
||||
@ -51,7 +52,7 @@ func (repo *Repository) readTreeToIndex(id ObjectID, indexFilename ...string) er
|
||||
|
||||
// ReadTreeToTemporaryIndex reads a treeish to a temporary index file
|
||||
func (repo *Repository) ReadTreeToTemporaryIndex(treeish string) (filename, tmpDir string, cancel context.CancelFunc, err error) {
|
||||
tmpDir, err = os.MkdirTemp(os.TempDir(), "index")
|
||||
tmpDir, err = os.MkdirTemp(setting.TempDir(), "index")
|
||||
if err != nil {
|
||||
return filename, tmpDir, cancel, err
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -16,9 +17,9 @@ import (
|
||||
// localCopyPath returns the local repository temporary copy path.
|
||||
func localCopyPath() string {
|
||||
if setting.Repository.Local.LocalCopyPath == "" {
|
||||
return filepath.Join(os.TempDir(), "local-repo")
|
||||
return filepath.Join(setting.TempDir(), "local-repo")
|
||||
} else if !filepath.IsAbs(setting.Repository.Local.LocalCopyPath) {
|
||||
return filepath.Join(os.TempDir(), setting.Repository.Local.LocalCopyPath)
|
||||
return filepath.Join(setting.TempDir(), setting.Repository.Local.LocalCopyPath)
|
||||
}
|
||||
return setting.Repository.Local.LocalCopyPath
|
||||
}
|
||||
@ -30,7 +31,7 @@ func CleanUpTemporaryPaths() {
|
||||
}
|
||||
|
||||
// CreateTemporaryPath creates a temporary path
|
||||
func CreateTemporaryPath(prefix string) (string, func(), error) {
|
||||
func CreateTemporaryPath(prefix string) (string, context.CancelFunc, error) {
|
||||
if err := os.MkdirAll(localCopyPath(), os.ModePerm); err != nil {
|
||||
log.Error("Unable to create localcopypath directory: %s (%v)", localCopyPath(), err)
|
||||
return "", func() {}, fmt.Errorf("failed to create localcopypath directory %s: %w", localCopyPath(), err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user