mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-01-18 20:20:45 +00:00
Handle database and profile upgrade for new versions.
This commit is contained in:
parent
04a64e1312
commit
cc7c13e17f
@ -24,7 +24,9 @@ import QtQuick.Controls 1.0
|
||||
import "utils.js" as Utils
|
||||
|
||||
QtObject{
|
||||
property string version: "1.0.1"
|
||||
readonly property string version: "1.0.1"
|
||||
readonly property int profileVersion: 2
|
||||
|
||||
|
||||
// STATIC CONSTANTS ////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -107,12 +107,15 @@ Tab{
|
||||
if (!name)
|
||||
throw "Profile doesn't have a name";
|
||||
|
||||
var version = profileObject.version !== undefined ? profileObject.version : 1;
|
||||
if (version !== appSettings.profileVersion)
|
||||
throw "This profile is not supported on this version of CRT.";
|
||||
|
||||
delete profileObject.name;
|
||||
|
||||
appSettings.appendCustomProfile(name, JSON.stringify(profileObject));
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
messageDialog.text = qsTr("There has been an error reading the file.")
|
||||
messageDialog.text = qsTr(err)
|
||||
messageDialog.open();
|
||||
}
|
||||
}
|
||||
@ -144,6 +147,7 @@ Tab{
|
||||
var profileObject = appSettings.profilesList.get(currentIndex);
|
||||
var profileSettings = JSON.parse(profileObject.obj_string);
|
||||
profileSettings["name"] = profileObject.text;
|
||||
profileSettings["version"] = appSettings.profileVersion;
|
||||
|
||||
var result = fileIO.write(url, JSON.stringify(profileSettings, undefined, 2));
|
||||
if (!result)
|
||||
|
@ -22,10 +22,12 @@ import QtQuick 2.2
|
||||
import QtQuick.LocalStorage 2.0
|
||||
|
||||
QtObject {
|
||||
readonly property string dbMajorVersion: "1"
|
||||
readonly property string dbMinorVersion: "1.0"
|
||||
property bool initialized: false
|
||||
|
||||
function getDatabase() {
|
||||
return LocalStorage.openDatabaseSync("coolretroterm", "1.0", "StorageDatabase", 100000);
|
||||
return LocalStorage.openDatabaseSync("coolretroterm" + dbMajorVersion, dbMinorVersion, "StorageDatabase", 100000);
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user