r90512 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90511‎ | r90512 | r90513 >
Date:06:49, 21 June 2011
Author:ariel
Status:deferred
Tags:
Comment:
deal with behavior change of mkstemp: config option for perms for temp files, explicitly set file perms for status/rss/index.html files
Modified paths:
  • /branches/ariel/xmldumps-backup/WikiDump.py (modified) (history)
  • /branches/ariel/xmldumps-backup/worker.py (modified) (history)

Diff [purge]

Index: branches/ariel/xmldumps-backup/worker.py
@@ -520,7 +520,7 @@
521521 def writeDumpRunInfoFile(self, text):
522522 directory = self._getDumpRunInfoDirName()
523523 dumpRunInfoFilename = self._getDumpRunInfoFileName()
524 - FileUtils.writeFile(directory, dumpRunInfoFilename, text)
 524+ FileUtils.writeFile(directory, dumpRunInfoFilename, text, self.wiki.config.fileperms)
525525
526526 def saveDumpRunInfoFile(self, done=False):
527527 """Write out a simple text file with the status for this wiki's dump."""
@@ -857,7 +857,7 @@
858858 # addnotice, stuff notice in a file for other jobs etc
859859 elif self.notice != "":
860860 noticeDir = self.getNoticeDir()
861 - FileUtils.writeFile(noticeDir, noticeFile, self.notice)
 861+ FileUtils.writeFile(noticeDir, noticeFile, self.notice, self.wiki.config.fileperms)
862862 # default case. if there is a file get the contents, otherwise
863863 # we have empty contents, all good
864864 else:
@@ -1265,7 +1265,7 @@
12661266 "date": time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime())}
12671267 directory = self.dumpDir.latestDir()
12681268 rssPath = self.dumpDir.latestPath(file + "-rss.xml")
1269 - FileUtils.writeFile(directory, rssPath, rssText)
 1269+ FileUtils.writeFile(directory, rssPath, rssText, self.config.fileperms)
12701270
12711271 class Dump(object):
12721272 def __init__(self, name, desc):
Index: branches/ariel/xmldumps-backup/WikiDump.py
@@ -19,12 +19,14 @@
2020 fd = os.open(filename, os.O_EXCL + os.O_CREAT + os.O_WRONLY)
2121 return os.fdopen(fd, mode)
2222
23 - def writeFile(dirname, filename, text):
 23+ def writeFile(dirname, filename, text, perms = 0):
2424 """Write text to a file, as atomically as possible, via a temporary file in the same directory."""
2525
2626 (fd, tempFilename ) = tempfile.mkstemp("_txt","wikidump_",dirname);
2727 os.write(fd,text)
2828 os.close(fd)
 29+ if (perms):
 30+ os.chmod(tempFilename,perms)
2931 # This may fail across filesystems or on Windows.
3032 # Of course nothing else will work on Windows. ;)
3133 os.rename(tempFilename, filename)
@@ -150,6 +152,7 @@
151153 "templatedir": home,
152154 "perdumpindex": "index.html",
153155 "logfile": "dumplog.txt",
 156+ "fileperms": "0640",
154157 #"reporting": {
155158 "adminmail": "root@localhost",
156159 "mailfrom": "root@localhost",
@@ -220,7 +223,8 @@
221224 self.templateDir = conf.get("output", "templateDir")
222225 self.perDumpIndex = conf.get("output", "perdumpindex")
223226 self.logFile = conf.get("output", "logfile")
224 -
 227+ self.fileperms = conf.get("output", "fileperms")
 228+ self.fileperms = int(self.fileperms,0)
225229 if not conf.has_section('reporting'):
226230 conf.add_section('reporting')
227231 self.adminMail = conf.get("reporting", "adminmail")
@@ -403,7 +407,7 @@
404408 def writePerDumpIndex(self, html):
405409 directory = os.path.join(self.publicDir(), self.date)
406410 index = os.path.join(self.publicDir(), self.date, self.config.perDumpIndex)
407 - FileUtils.writeFile(directory, index, html)
 411+ FileUtils.writeFile(directory, index, html, self.config.fileperms)
408412
409413 def existsPerDumpIndex(self):
410414 index = os.path.join(self.publicDir(), self.date, self.config.perDumpIndex)
@@ -412,7 +416,7 @@
413417 def writeStatus(self, message):
414418 directory = os.path.join(self.publicDir(), self.date)
415419 index = os.path.join(self.publicDir(), self.date, "status.html")
416 - FileUtils.writeFile(directory, index, message)
 420+ FileUtils.writeFile(directory, index, message, self.config.fileperms)
417421
418422 def statusLine(self):
419423 date = self.latestDump()

Status & tagging log