Ticket #7164 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

TracLegosScript silently overwrites existing projects

Reported by: anonymous Assigned to: ejucovy
Priority: normal Component: TracLegosScript
Severity: normal Keywords:
Cc: slinkp@gmail.com Trac Release: 0.11

Description

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.

I'd prefer the default behavior to be bailing out. Rationale: if the script bails out, but you really meant to wipe the project, you can proceed in seconds by manually rm -rfing 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.

Here's a 4-line patch that just raises an exception, no change to command line args or anything nice like that:

Index: legos.py
===================================================================
--- legos.py	(revision 8010)
+++ legos.py	(working copy)
@@ -115,6 +115,10 @@
         ### set variables
 
         dirname = os.path.join(self.directory, project)
+        if os.path.isdir(dirname) and os.listdir(dirname):
+           raise ValueError("Project directory %r already exists, "
+	                    "cowardly refusing to create anything" % dirname)
+
         _vars = vars or {}
         vars = self.vars.copy()
         vars.update(_vars)

Attachments

Change History

05/25/10 18:59:13 changed by anonymous

  • cc set to slinkp@gmail.com.

06/02/10 19:24:47 changed by anonymous

  • status changed from new to closed.
  • resolution set to fixed.

Thanks, committed in r8058.

06/02/10 19:25:09 changed by ejucovy

(That was me)


Add/Change #7164 (TracLegosScript silently overwrites existing projects)




Change Properties
Action