Index: trunk/backup/WikiBackup.py |
— | — | @@ -122,7 +122,8 @@ |
123 | 123 | |
124 | 124 | def __init__(self, public, private, dblist, privatelist, dbserver, |
125 | 125 | dbuser, dbpassword, wikidir, php="php", webroot="", |
126 | | - template=dirname(realpath(sys.modules[__module__].__file__))): |
| 126 | + template=dirname(realpath(sys.modules[__module__].__file__)), |
| 127 | + tmp="/tmp"): |
127 | 128 | self.public = public |
128 | 129 | self.private = private |
129 | 130 | self.dblist = dblist |
— | — | @@ -134,6 +135,7 @@ |
135 | 136 | self.php = php |
136 | 137 | self.webroot = webroot |
137 | 138 | self.template = template |
| 139 | + self.tmp = tmp |
138 | 140 | self.db = None |
139 | 141 | self.date = None |
140 | 142 | self.failcount = 0 |
— | — | @@ -188,6 +190,10 @@ |
189 | 191 | """ |
190 | 192 | return self.buildPath(self.publicDir(), self.date, filename) |
191 | 193 | |
| 194 | + def tmpPath(self, filename): |
| 195 | + """Return a filename in the temporary directory based on the given name.""" |
| 196 | + return join(self.tmp, self.db + "-tmp-" + filename) |
| 197 | + |
192 | 198 | def latestPath(self, filename): |
193 | 199 | return self.buildPath(self.latestDir(), "latest", filename) |
194 | 200 | |
— | — | @@ -624,6 +630,12 @@ |
625 | 631 | return "creating split stub dumps..." |
626 | 632 | |
627 | 633 | def run(self, runner): |
| 634 | + history = runner.tmpPath("stub-meta-history.xml.gz") |
| 635 | + current = runner.tmpPath("stub-meta-current.xml.gz") |
| 636 | + articles = runner.tmpPath("stub-articles.xml.gz") |
| 637 | + for filename in (history, current, articles): |
| 638 | + if exists(filename): |
| 639 | + remove(filename) |
628 | 640 | command = """ |
629 | 641 | %s -q %s/maintenance/dumpBackup.php %s \ |
630 | 642 | --full \ |
— | — | @@ -639,9 +651,9 @@ |
640 | 652 | runner.php, |
641 | 653 | runner.wikidir, |
642 | 654 | runner.db, |
643 | | - runner.privatePath("stub-meta-history.xml.gz"), |
644 | | - runner.privatePath("stub-meta-current.xml.gz"), |
645 | | - runner.privatePath("stub-articles.xml.gz"))) |
| 655 | + history, |
| 656 | + current, |
| 657 | + articles)) |
646 | 658 | runner.runCommand(command) |
647 | 659 | |
648 | 660 | class XmlDump(Dump): |
— | — | @@ -680,7 +692,7 @@ |
681 | 693 | """Build the command line for the dump, minus output and filter options""" |
682 | 694 | |
683 | 695 | # Page and revision data pulled from this skeleton dump... |
684 | | - stub = runner.privatePath("stub-%s.xml.gz" % self._subset), |
| 696 | + stub = runner.tmpPath("stub-%s.xml.gz" % self._subset), |
685 | 697 | stubOption = "--stub=gzip:%s" % stub |
686 | 698 | |
687 | 699 | # Try to pull text from the previous run; most stuff hasn't changed |