Edgewall Software
Modify

Opened 19 years ago

Closed 19 years ago

Last modified 19 years ago

#1203 closed defect (fixed)

trac-admin's wiki dump feature fails on hierarchical pages

Reported by: peter.fischer@… Owned by: Mark Rowe
Priority: normal Milestone: 0.9
Component: admin/console Version: 0.8
Severity: normal Keywords: rac-admin wiki dump hierarchical pages
Cc: peter.fischer@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I have hierarchcal wikipages in one of my trac wikis e.g.: http://trac.srv/infrastruktur/wiki/TerraSelEinkauf/IngramMicro

http://projects.edgewall.com/trac/wiki/WikiPageNames does allow this:

5. The use of slash ( / ) is permitted to create a hierarchy inside the wiki.

Error description: if I want to dump all wiki pages using trac-admin's wiki dump function, the following occurs:

apache ~% mkdir test
apache ~% cd test
apache ~/test% mkdir dumpdestination
apache ~/test% trac-admin /var/lib/trac/infrastruktur wiki dump dumpdestination
 TracReports => dumpdestination/TracReports
[...lots of wiki root level pages being dumped correctly...]
 TelefonListe => dumpdestination/TelefonListe
 TerraSelEinkauf => dumpdestination/TerraSelEinkauf
 TerraSelEinkauf/IngramMicro => dumpdestination/TerraSelEinkauf/IngramMicro
Wiki dump failed: [Errno 20] Not a directory: 'dumpdestination/TerraSelEinkauf/IngramMicro'
apache ~/test%

The bug consists of three errors:

  • Dumping hierarchical wikipages using trac-admin's wiki dump function does not work.
  • trac-admin breaks after error, so all pages after the first hierarchical one are ommitted, too.
  • trac-admin does not inform about its failure, so a backup script can not decide about success or error:
     TerraSelEinkauf/IngramMicro => dumpdestination/TerraSelEinkauf/IngramMicro
    Wiki dump failed: [Errno 20] Not a directory: 'dumpdestination/TerraSelEinkauf/IngramMicro'
    apache ~/test% echo $?
    0
    

I use gentoo linux and stock trac 0.8.

Attachments (0)

Change History (6)

comment:1 by osamu.hashimoto@…, 19 years ago

Replace trac-admin function with following code.

I test it on Windows XP.

    def _do_wiki_export(self, page,filename=''):
        data=self.db_execsql("SELECT text FROM wiki "
                             " WHERE name='%s'"
                             " ORDER BY version DESC LIMIT 1" % page)
        text = data[0][0]
        if not filename:
            print text
        else:
            if os.path.isfile(filename):
                raise Exception("File '%s' exists" % filename)
            if not os.path.isdir(os.path.dirname(filename)):
                os.makedirs(os.path.dirname(filename))
            f = open(filename,'w')
            f.write(text)
            f.close()

    def _do_wiki_dump(self, dir):
        pages = self.get_wiki_list()
        for p in pages:
            lp=unicode( p,"utf-8").encode(encoding)
            dst = os.path.join(dir,lp)
            print " %s => %s" % (lp, dst)
            self._do_wiki_export(p, dst)

    def _do_wiki_load(self, dir,cursor=None, ignore=[], prefix=""):
        for page in os.listdir(dir):
            if page in ignore:
                continue
            entry = os.path.join(dir, page)
	    if not prefix == "":
                page = prefix + '/' + page 
            if os.path.isfile(entry):
                print " %s => %s" % (entry, page)
                self._do_wiki_import(entry,unicode(page,encoding).encode("utf-8"),  cursor)
            if os.path.isdir(entry):
                self._do_wiki_load(entry,None,[],page)


comment:2 by Mark Rowe, 19 years ago

I believe that the code you suggest will break when you have both FooBar and FooBar/BarFoo as you cannot have a file + directory of the same name. A possible solution may be to output the files with their names URL-encoded. This would result in files named FooBar and FooBar%2FBarFoo being created for the case mentioned above.

comment:3 by Mark Rowe, 19 years ago

Owner: changed from daniel to Mark Rowe
Status: newassigned

comment:4 by Mark Rowe, 19 years ago

Resolution: fixed
Status: assignedclosed

This is fixed in [1504].

comment:5 by anonymous, 19 years ago

Milestone: 0.9

comment:6 by Matthew Good, 19 years ago

#1628 has been marked as a duplicate of this ticket.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Mark Rowe.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Mark Rowe to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.