changeset 20:32dc46f22c2a 0.2.1

Fixed issue with Windows temporary file locking. IN: -
author John Schneiderman <JohnMS@CodeGNU.org>
date Tue, 29 Jul 2014 09:07:57 -0500
parents ab317a52e5b4
children 9690b422d6df
files doc/ChangeLog src/manager.py
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/doc/ChangeLog	Mon Jul 28 18:48:13 2014 -0500
+++ b/doc/ChangeLog	Tue Jul 29 09:07:57 2014 -0500
@@ -17,8 +17,9 @@
 ***  You should have received a copy of the GNU Affero General Public License***
 ***  along with this program. If not, see <http://www.gnu.org/licenses/>.    ***
 ********************************************************************************
-2014-07-28 John Schneiderman <Licensing _AT_ CodeGNU _DOT_ com> 0.2.1
+2014-07-29 John Schneiderman <Licensing _AT_ CodeGNU _DOT_ com> 0.2.1
 - Fixed issue where the configuration file copy started before it closed.
+- Fixed issue in Windows locking temporary file and preventing copying.
 2014-07-26 John Schneiderman <Licensing _AT_ CodeGNU _DOT_ com> 0.2.0
 - Ability to modify an existing repository.
 - Load a managed repository object from it's storage name.
--- a/src/manager.py	Mon Jul 28 18:48:13 2014 -0500
+++ b/src/manager.py	Tue Jul 29 09:07:57 2014 -0500
@@ -258,7 +258,9 @@
 	import shutil
 
 	foundRepo=False
-	with tempfile.NamedTemporaryFile() as target:
+	tempFile=None
+	with tempfile.NamedTemporaryFile(delete=False) as target:
+		tempFile = target.name
 		with open(settings.HgWebPath + os.sep + 'hgweb.config', 'r') as source:
 			for line in source:
 				if repo.StorageName in line:
@@ -270,7 +272,12 @@
 			while not source.closed:
 				print "Waiting three seconds for configuration to close."
 				time.sleep(3)
-		shutil.copy2(target.name, settings.HgWebPath + os.sep + 'hgweb.config')
+	try:
+		shutil.copy2(tempFile, settings.HgWebPath + os.sep + 'hgweb.config')
+	except IOError as e:
+		print >>sys.stderr, "Unregister error({0}): {1}".format(e.errno, e.strerror)
+		foundRepo = False
+	os.remove(tempFile)
 	return foundRepo
 
 def __removeRepository(repo):