r83009 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83008‎ | r83009 | r83010 >
Date:08:53, 1 March 2011
Author:ariel
Status:deferred
Tags:
Comment:
only update link in 'latest' directory if our run date is later than what's there
Modified paths:
  • /branches/ariel/xmldumps-backup/worker.py (modified) (history)

Diff [purge]

Index: branches/ariel/xmldumps-backup/worker.py
@@ -1122,13 +1122,25 @@
11231123 link = self.dumpDir.latestPath(file)
11241124 if exists(link) or os.path.islink(link):
11251125 if os.path.islink(link):
1126 - self.debug("Removing old symlink %s" % link)
1127 - os.remove(link)
 1126+ realfile = os.readlink(link)
 1127+ # format of these links should be... ../20110228/elwikidb-20110228-templatelinks.sql.gz
 1128+ rellinkpattern = re.compile('^\.\./(20[0-9]+)/');
 1129+ dateinlink = rellinkpattern.search(realfile)
 1130+ if (dateinlink):
 1131+ dateoflinkedfile = dateinlink.group(1)
 1132+ dateinterval = int(self.date) - int(dateoflinkedfile)
 1133+ else:
 1134+ dateinterval = 0
 1135+ # no file or it's older than ours... *then* remove the link
 1136+ if not exists(os.path.realpath(link)) or dateinterval > 0:
 1137+ self.debug("Removing old symlink %s" % link)
 1138+ os.remove(link)
11281139 else:
11291140 self.logAndPrint("What the hell dude, %s is not a symlink" % link)
11301141 raise BackupError("What the hell dude, %s is not a symlink" % link)
11311142 relative = relativePath(real, dirname(link))
1132 - if exists(real):
 1143+ # if we removed the link cause it's obsolete, make the new one
 1144+ if exists(real) and not exists(link):
11331145 self.debug("Adding symlink %s -> %s" % (link, relative))
11341146 os.symlink(relative, link)
11351147

Status & tagging log