mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-24 02:43:42 -05:00
Customizing the error message for dolt init when a sql-server is already running from the directory
This commit is contained in:
@@ -104,6 +104,12 @@ func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, d
|
||||
types.Format_Default = types.Format_DOLT
|
||||
}
|
||||
|
||||
if dEnv.HasDoltSqlServerInfo() {
|
||||
cli.PrintErrln(color.RedString("Detected that a Dolt sql-server is running from this directory. " +
|
||||
"Stop the sql-server before initializing this directory as a Dolt database."))
|
||||
return 1
|
||||
}
|
||||
|
||||
name, _ := apr.GetValue(usernameParamName)
|
||||
email, _ := apr.GetValue(emailParamName)
|
||||
initBranch, _ := apr.GetValue(initBranchParamName)
|
||||
|
||||
+7
@@ -303,6 +303,13 @@ func (dEnv *DoltEnv) HasDoltDataDir() bool {
|
||||
return exists && isDir
|
||||
}
|
||||
|
||||
// HasDoltSqlServerInfo returns true if this Dolt environment has a sql-server.info file, indicating
|
||||
// that a sql-server is running from this Dolt environment.
|
||||
func (dEnv *DoltEnv) HasDoltSqlServerInfo() bool {
|
||||
exists, _ := dEnv.FS.Exists(filepath.Join(dbfactory.DoltDir, "sql-server.info"))
|
||||
return exists
|
||||
}
|
||||
|
||||
func (dEnv *DoltEnv) HasDoltTempTableDir() bool {
|
||||
tmpDir, err := dEnv.TempTableFilesDir()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user