Browse Source

Fix: add missing parameter in Windows platform code

Rod Hynes 8 years ago
parent
commit
e3a8ea4f71
3 changed files with 14 additions and 4 deletions
  1. 2 1
      psiphon/dataStore.go
  2. 1 1
      psiphon/migrateDataStore.go
  3. 11 2
      psiphon/migrateDataStore_windows.go

+ 2 - 1
psiphon/dataStore.go

@@ -159,7 +159,8 @@ func InitDataStore(config *Config) (err error) {
 		// initialized prior to execution so that migrated entries can be stored
 
 		if len(migratableServerEntries) > 0 {
-			migrateEntries(migratableServerEntries, filepath.Join(config.DataStoreDirectory, LEGACY_DATA_STORE_FILENAME))
+			migrateEntries(
+				config, migratableServerEntries, filepath.Join(config.DataStoreDirectory, LEGACY_DATA_STORE_FILENAME))
 		}
 
 		resetAllPersistentStatsToUnreported()

+ 1 - 1
psiphon/migrateDataStore.go

@@ -31,5 +31,5 @@ func prepareMigrationEntries(config *Config) []*protocol.ServerEntry {
 }
 
 // Stub function to return immediately for non-Windows builds
-func migrateEntries(serverEntries []*protocol.ServerEntry, legacyDataStoreFilename string) {
+func migrateEntries(config *Config, serverEntries []*protocol.ServerEntry, legacyDataStoreFilename string) {
 }

+ 11 - 2
psiphon/migrateDataStore_windows.go

@@ -85,7 +85,7 @@ func prepareMigrationEntries(config *Config) []*protocol.ServerEntry {
 // migrateEntries calls the BoltDB data store method to shuffle
 // and store an array of server entries (StoreServerEntries)
 // Failing to migrate entries, or delete the legacy file is never fatal
-func migrateEntries(serverEntries []*protocol.ServerEntry, legacyDataStoreFilename string) {
+func migrateEntries(config *Config, serverEntries []*protocol.ServerEntry, legacyDataStoreFilename string) {
 	checkInitDataStore()
 
 	err := StoreServerEntries(serverEntries, false)
@@ -95,7 +95,16 @@ func migrateEntries(serverEntries []*protocol.ServerEntry, legacyDataStoreFilena
 		// Retain server affinity from old datastore by taking the first
 		// array element (previous top ranked server) and promoting it
 		// to the top rank before the server selection process begins
-		err = PromoteServerEntry(serverEntries[0].IpAddress)
+		//
+		// TODO: we don't know what server entry filters were in place
+		// at the time when the legacy datastore was last updated.
+		// PromoteServerEntry now records the server entry filter in
+		// order to break server affinity when the filter changes.
+		// For now, we promote with the current server entry filter
+		// so the legacy server affinity is retained. This is the same
+		// logic as was in place before we added recording the server
+		// entry filter.
+		err = PromoteServerEntry(config, serverEntries[0].IpAddress)
 		if err != nil {
 			NoticeAlert("migrateEntries: PromoteServerEntry failed: %s", err)
 		}