rpms/deluge/devel deluge-fix-persistence-upgrade-rhbz_247927.patch, NONE, 1.1 deluge.spec, 1.17, 1.18

Peter Gordon (pgordon) fedora-extras-commits at redhat.com
Sat Jul 14 19:06:02 UTC 2007


Author: pgordon

Update of /cvs/extras/rpms/deluge/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv24163

Modified Files:
	deluge.spec 
Added Files:
	deluge-fix-persistence-upgrade-rhbz_247927.patch 
Log Message:
Add patch to automatically update or remove stale persistent state files as needed (fixes startup, bug 247927).

deluge-fix-persistence-upgrade-rhbz_247927.patch:

--- NEW FILE deluge-fix-persistence-upgrade-rhbz_247927.patch ---
--- scripts/deluge.old	2007-07-11 20:28:51.000000000 -0700
+++ scripts/deluge	2007-07-13 16:16:43.000000000 -0700
@@ -39,6 +40,7 @@
 import os, os.path
 import gettext, locale
 import deluge, deluge.common, deluge.interface
+import re
 try:
 	import dbus
 	dbus_version = getattr(dbus, 'version', (0,0,0))
@@ -64,6 +66,36 @@
 
 def start_deluge():
 	print "Starting new Deluge session..."
+	pstate_file_path = os.getenv("HOME") + "/.config/deluge/persistent.state"
+	## The persistent_state object moved from the deluge.deluge module to the
+	## deluge.core module from 0.5; so let's edit the user's saved data to reflect
+	## this.
+	if os.path.isfile(pstate_file_path):
+		try:
+			pstate_fd = open(pstate_file_path, "r")
+			pstate_data = pstate_fd.read()
+			pstate_fd.close()
+			
+			## If the file was empty, then we should remove it so that the
+			## pickler doesn't not attempt to unpack an empty state.
+			if len(pstate_data) is 0:
+				os.remove(pstate_file_path)
+				print "Empty persistent state data file removed successfully."
+			## The file exists and contains data, so let's do a regex-based
+			## find/replace to update the module name.
+			else:
+				pstate_fd_new = open(pstate_file_path, "w")
+				pstate_old_regex = re.compile("""^\(ideluge\.deluge$""", re.MULTILINE)
+				pstate_new_data = re.sub(pstate_old_regex, "(ideluge.core", pstate_data)
+				pstate_fd_new.write(pstate_new_data)
+				pstate_fd_new.close()
+				print "Persistent state data updated successfully."
+		except OSError, oopsie: 
+			print >> sys.stderr, "There was an error updating the persistent.state file.\n"		\
+				"If this is an upgrade from an earlier version of Deluge, this may cause"	\
+				"bugs or failures in startup. You may wish to remove it manually."		\
+				"(%s) Continuing..." % state_file
+			print >> sys.stderr, "The error was: %s." % oopsie
 	interface = deluge.interface.DelugeGTK()
 	add_args(interface)
 	interface.start()


Index: deluge.spec
===================================================================
RCS file: /cvs/extras/rpms/deluge/devel/deluge.spec,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- deluge.spec	10 Jul 2007 06:49:57 -0000	1.17
+++ deluge.spec	14 Jul 2007 19:05:30 -0000	1.18
@@ -1,9 +1,9 @@
-%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
+	%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
 %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
 
 Name:		deluge
 Version:	0.5.2
-Release:	1%{?dist}
+Release:	2%{?dist}
 Summary:	A GTK+ BitTorrent client with support for DHT, UPnP, and PEX.
 Group:		Applications/Internet
 License:	GPL
@@ -13,6 +13,7 @@
 ## Not used for now: Deluge builds against its own internal copy of
 ## rb_libtorrent. See below for more details. 
 # Source1:	%{name}-fixed-setup.py
+Patch0:		%{name}-fix-persistence-upgrade-rhbz_247927.patch
 
 BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -60,6 +61,7 @@
 %setup -q
 ## Not building against system rb_libtorrent - see above.
 # install -m 0755 %{SOURCE1} ./setup.py
+%patch0 -p0 -b .fix-persistence-upgrade-rhbz_247927
 
 
 %build
@@ -105,6 +107,12 @@
 
 
 %changelog
+* Wed Jul 11 2007 Peter Gordon <peter at thecodergeek.com> - 0.5.2-2
+- Add patch to fix the existence of stale persistence files by automatically
+  updating the deluge.deluge module name to deluge.core, or removing them if
+  empty (bug 247927):
+    + fix-persistence-upgrade-rhbz_247927.patch
+
 * Sun Jul 08 2007 Peter Gordon <peter at thecodergeek.com> - 0.5.2-1
 - Update to new upstream release (0.5.2)
 - Update Summary and %%description to reflect new µTorrent-compatible Peer




More information about the scm-commits mailing list