Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#7164 closed enhancement (fixed)

TracLegosScript silently overwrites existing projects

Reported by: anonymous Owned by: ejucovy
Priority: normal Component: TracLegosScript
Severity: normal Keywords:
Cc: slinkp@… Trac Release: 0.11


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.
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:

---	(revision 8010)
+++	(working copy)
@@ -115,6 +115,10 @@
         ### set variables
         dirname = os.path.join(, 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()

Attachments (0)

Change History (3)

comment:1 Changed 4 years ago by anonymous

  • Cc slinkp@… added

comment:2 Changed 4 years ago by anonymous

  • Resolution set to fixed
  • Status changed from new to closed

Thanks, committed in r8058.

comment:3 Changed 4 years ago by ejucovy

(That was me)

Add Comment

Modify Ticket

as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from ejucovy. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.