id,summary,reporter,owner,description,type,status,priority,component,severity,resolution,keywords,cc,release
7164,TracLegosScript silently overwrites existing projects,anonymous,ejucovy,If you run create-trac-project with the name of a project that already exists_ it will silently be created from scratch_ wiping out whatever was there. At least with sqlite_ this includes losing your database.\r\n\r\nI'd prefer the default behavior to be bailing out. \r\nRationale:\r\nif the script bails out_ but you really meant to wipe the project_ you can proceed in seconds by manually `rm -rf`ing it.  On the other hand_ if the script silently wipes out your project_ and you had data in the database_ it might take you hours to recover ... depending on your backup situation_ if you even have one.\r\n\r\nHere's a 4-line patch that just raises an exception_ no change to command line args or anything nice like that:\r\n\r\n{{{\r\nIndex: legos.py\r\n===================================================================\r\n--- legos.py	(revision 8010)\r\n+++ legos.py	(working copy)\r\n@@ -115_6 +115_10 @@\r\n         ### set variables\r\n \r\n         dirname = os.path.join(self.directory_ project)\r\n+        if os.path.isdir(dirname) and os.listdir(dirname):\r\n+           raise ValueError("Project directory %r already exists_ "\r\n+	                    "cowardly refusing to create anything" % dirname)\r\n+\r\n         _vars = vars or {}\r\n         vars = self.vars.copy()\r\n         vars.update(_vars)\r\n}}},enhancement,closed,normal,TracLegosScript,normal,fixed,,slinkp@gmail.com,0.11
