4.3.0 version fix and macOS data path.

Fixed my typo with 4.3. version - it is detected as 4.3.0, not 4.3.000.

Possibly, macOS version is now true :).
This commit is contained in:
Stanislav Nikitin 2016-10-04 18:32:50 +05:00
parent b7e79ce01b
commit 812436fce3
3 changed files with 26 additions and 2 deletions

View File

@ -22,6 +22,18 @@ type Config struct {
TEMP map[string]string
}
func (c *Config) initializePathsMac() {
fmt.Println("Initializing configuration paths...")
home_path := os.Getenv("HOME")
data_path := path.Join(home_path, "Library", "Application Support", "URTrator")
fmt.Println("Will use data path: " + data_path)
c.TEMP["DATA"] = data_path
if _, err := os.Stat(data_path); os.IsNotExist(err) {
os.MkdirAll(data_path, 0755)
}
}
func (c *Config) initializePathsNix() {
fmt.Println("Initializing configuration paths...")
@ -47,6 +59,8 @@ func (c *Config) Initialize() {
if runtime.GOOS == "linux" {
c.initializePathsNix()
} else if runtime.GOOS == "darwin" {
c.initializePathsMac()
} else {
panic("We're not ready for other OSes yet!")
}

View File

@ -51,6 +51,10 @@ func migrate_full(db *Database, version int) {
two_to_three(db)
version = 3
}
if version == 3 {
three_to_four(db)
version = 4
}
}
// Initial database structure.
@ -75,3 +79,9 @@ func two_to_three(db *Database) {
db.Db.MustExec("CREATE TABLE urt_profiles (name VARCHAR(128) NOT NULL, version VARCHAR(5) NOT NULL DEFAULT '4.3', binary VARCHAR(1024) NOT NULL, second_x_session VARCHAR(1) NOT NULL DEFAULT '0', additional_parameters VARCHAR(1024) NOT NULL DEFAULT '')")
db.Db.MustExec("UPDATE database SET version=3")
}
// UrT version inconsistency.
func three_to_four(db *Database) {
fmt.Println("Upgrading database from 3 to 4...")
db.Db.MustExec("UPDATE urt_profiles SET version='4.3.0' WHERE version='4.3.000'")
}

View File

@ -131,7 +131,7 @@ func (op *OptionsProfile) Initialize(update bool, lp func()) {
urt_version_sep := gtk.NewHSeparator()
op.urt_version_combo = gtk.NewComboBoxText()
op.urt_version_combo.AppendText("4.2.023")
op.urt_version_combo.AppendText("4.3.000")
op.urt_version_combo.AppendText("4.3.0")
op.urt_version_combo.SetActive(1)
urt_version_hbox.PackStart(urt_version_label, false, true, 5)
urt_version_hbox.PackStart(urt_version_sep, true, true, 5)
@ -212,7 +212,7 @@ func (op *OptionsProfile) InitializeUpdate(profile_name string, lp func()) {
op.another_x_session.SetActive(true)
}
if profile[0].Version == "4.3.000" {
if profile[0].Version == "4.3.0" {
op.urt_version_combo.SetActive(1)
} else {
op.urt_version_combo.SetActive(0)