diff options
-rw-r--r-- | pkg/commands/files.go | 2 | ||||
-rw-r--r-- | pkg/config/app_config.go | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/pkg/commands/files.go b/pkg/commands/files.go index 5ad6eeb66..74beb9fb7 100644 --- a/pkg/commands/files.go +++ b/pkg/commands/files.go @@ -224,7 +224,7 @@ func (c *GitCommand) WorktreeFileDiffCmdStr(node models.IFile, plain bool, cache } func (c *GitCommand) ApplyPatch(patch string, flags ...string) error { - filepath := filepath.Join(c.Config.GetUserConfigDir(), utils.GetCurrentRepoName(), time.Now().Format("Jan _2 15.04.05.000000000")+".patch") + filepath := filepath.Join(c.Config.GetTempDir(), utils.GetCurrentRepoName(), time.Now().Format("Jan _2 15.04.05.000000000")+".patch") c.Log.Infof("saving temporary patch to %s", filepath) if err := c.OSCommand.CreateFileWithContent(filepath, patch); err != nil { return err diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index b6d668439..6adfb9919 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -21,6 +21,7 @@ type AppConfig struct { UserConfig *UserConfig UserConfigDir string UserConfigPath string + TempDir string AppState *AppState IsNewRepo bool } @@ -37,6 +38,7 @@ type AppConfigurer interface { GetUserConfig() *UserConfig GetUserConfigDir() string GetUserConfigPath() string + GetTempDir() string GetAppState() *AppState SaveAppState() error SetIsNewRepo(bool) @@ -60,6 +62,8 @@ func NewAppConfig(name, version, commit, date string, buildSource string, debugg debuggingFlag = true } + tempDir := filepath.Join(os.TempDir(), "lazygit") + appState, err := loadAppState() if err != nil { return nil, err @@ -75,6 +79,7 @@ func NewAppConfig(name, version, commit, date string, buildSource string, debugg UserConfig: userConfig, UserConfigDir: configDir, UserConfigPath: filepath.Join(configDir, "config.yml"), + TempDir: tempDir, AppState: appState, IsNewRepo: false, } @@ -204,6 +209,10 @@ func (c *AppConfig) GetUserConfigDir() string { return c.UserConfigDir } +func (c *AppConfig) GetTempDir() string { + return c.TempDir +} + func (c *AppConfig) ReloadUserConfig() error { userConfig, err := loadUserConfigWithDefaults(c.UserConfigDir) if err != nil { |