recover missing mtime from edit log

This commit is contained in:
Elan Ruusamäe 2012-09-19 21:01:52 +02:00
parent 850301acfa
commit ff310ead06

View file

@ -163,17 +163,20 @@ def convertfile(pagedir, output = None, overwrite = False):
pagefile, realrev, exists = page.get_rev(rev = rev); pagefile, realrev, exists = page.get_rev(rev = rev);
content = moin2doku(pagename, page.get_raw_body()) content = moin2doku(pagename, page.get_raw_body())
mtime = page.mtime_usecs() / USEC
if not page.mtime_usecs(): if not mtime:
print "NO REVISION: %s" % page.mtime_usecs() if os.path.exists(pagefile):
# TODO file exists, but no mtime, recover from filename mtime = int(os.path.getmtime(pagefile))
continue
if not mtime:
print "NO REVISION: for %s" % pagefile
continue
if rev == current_rev: if rev == current_rev:
out_file = os.path.join(output_dir, 'pages', dw.wikiFN(output)) out_file = os.path.join(output_dir, 'pages', dw.wikiFN(output))
else: else:
mtime = str(page.mtime_usecs() / USEC) out_file = os.path.join(output_dir, 'attic', dw.wikiFN(output, str(mtime)))
out_file = os.path.join(output_dir, 'attic', dw.wikiFN(output, mtime))
writefile(out_file, content, overwrite = overwrite) writefile(out_file, content, overwrite = overwrite)
copystat(pagefile, out_file) copystat(pagefile, out_file)