Fix a few issues related to upgrading.

This commit is contained in:
FelisCatus 2014-11-27 19:56:58 +08:00
parent d8d54f4b43
commit 17427ae13f
3 changed files with 23 additions and 2 deletions

View File

@ -3,6 +3,9 @@ Revision =
time = if time then new Date(time) else new Date()
return time.getTime().toString(16)
compare: (a, b) ->
return 0 if not a and not b
return -1 if not a
return 1 if not b
return 1 if a.length > b.length
return -1 if a.length < b.length
return 1 if a > b

View File

@ -27,14 +27,15 @@ module.exports = class SwitchySharp
if @_monitorTimerId
clearInterval @_monitorTimerId
@_monitorTimerId = null
if @_getOptionsResolver
@port.postMessage({action: 'getOptions'})
switch msg?.action
when 'state'
# State changed.
OmegaTarget.Log.log(msg)
if @_getOptionsResolver
@port.postMessage({action: 'getOptions'})
when 'options'
@_getOptionsResolver?(msg.options)
@_getOptionsResolver = null
_onDisconnect: (msg) ->
@port = null

View File

@ -48,6 +48,7 @@ module.exports = (oldOptions, i18n) ->
'purple': '#d497ee'
'': '#99ccee'
seenFixedProfile = false
for own _, oldProfile of oldProfiles
profile = null
switch oldProfile['proxyMode']
@ -64,6 +65,7 @@ module.exports = (oldOptions, i18n) ->
else
profile.pacUrl = url
when 'manual'
seenFixedProfile = true
profile = OmegaPac.Profiles.create(
profileType: 'FixedProfile'
)
@ -116,6 +118,21 @@ module.exports = (oldOptions, i18n) ->
OmegaPac.Profiles.updateRevision(profile)
options[OmegaPac.Profiles.nameAsKey(profile.name)] = profile
if not seenFixedProfile
exampleFixedProfileName = 'Example Profile'
options[OmegaPac.Profiles.nameAsKey(exampleFixedProfileName)] =
bypassList: [
pattern: "<local>"
conditionType: "BypassCondition"
]
profileType: "FixedProfile"
name: exampleFixedProfileName
color: "#99ccee"
fallbackProxy:
port: 8080
scheme: "http"
host: "proxy.example.com"
startupId = config['startupProfileId']
options['-startupProfileName'] = nameMap[startupId] || ''