Commits

Jakob Westhoff committed c94fce0

Leftover changes from last commit

Comments (0)

Files changed (2)

src/revelation-applet.py

 		"Sets up facilities"
 
 		self.clipboard		= data.Clipboard()
-		self.datafile		= io.DataFile(datahandler.Revelation)
+		self.datafile		= io.DataFile(datahandler.Revelation2)
 		self.entrystore		= data.EntryStore()
 		self.entrysearch	= data.EntrySearch(self.entrystore)
 		self.items		= ui.ItemFactory(self.applet)

src/revelation.py

 
 		self.clipboard		= data.Clipboard()
 		self.config		= config.Config()
-		self.datafile		= io.DataFile(datahandler.Revelation)
+		self.datafile		= io.DataFile(datahandler.Revelation2)
 		self.entryclipboard	= data.EntryClipboard()
 		self.entrystore		= data.EntryStore()
 		self.entrysearch	= data.EntrySearch(self.entrystore)
 	def __file_load(self, file, password, datafile = None):
 		"Loads data from a data file into an entrystore"
 
+		# We may need to change the datahandler
+		old_handler = None
+
 		try:
 			if datafile is None:
 				datafile = self.datafile
 
+				# Because there are two fileversion we need to check if we are really dealing
+				# with version two. If we aren't chances are high, that we are
+				# dealing with version one. In this case we use the version one
+				# handler and save the file as version two if it is changed, to
+				# allow seemless upgrades.
+				if datafile.get_handler().detect(io.file_read(file)) != True:
+					# Store the datahandler to be reset later on
+					old_handler = datafile.get_handler()
+					# Load the revelation fileversion one handler
+					datafile.set_handler(datahandler.Revelation)
+
 			while 1:
 				try:
 					return datafile.load(file, password, lambda: dialog.PasswordOpen(self, os.path.basename(file)).run())
 			self.statusbar.set_status(_('Open failed'))
 			dialog.Error(self, _('Unable to open file'), _('The file \'%s\' could not be opened. Make sure that the file exists, and that you have permissions to open it.') % file).run()
 
+		# If we switched the datahandlers before we need to switch back to the
+		# version2 handler here, to ensure a seemless version upgrade on save
+		if old_handler != None:
+			datafile.set_handler(old_handler)
+
 
 	def __get_common_usernames(self, e = None):
 		"Returns a list of possibly relevant usernames"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.