Skip to content

Commit 0c72fcb

Browse files
committed
Delete old revisions of a page after fetching a newer one
1 parent 4339efe commit 0c72fcb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

htmldumper.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ function* dumpArticle (prefix, title, oldid) {
8686

8787
// strip data-parsoid
8888
body = body.replace(/ ?data-parsoid=(?:'[^']+'|"[^"]+"|\\".*?\\"|'.*?')/g, '');
89+
var files = yield fs.readdir(dirName, resume());
90+
files.forEach(function(file, cb) {
91+
fs.unlink(file, cb);
92+
});
8993
return yield fs.writeFile(fileName, body, resume());
9094
}
9195

@@ -130,7 +134,7 @@ function* makeDump (apiURL, prefix, ns) {
130134
try {
131135
return yield* dumpArticle(prefix, title, oldid);
132136
} catch (e) {
133-
console.error('Error in makeDump:', title, oldid, e);
137+
console.error('Error in makeDump:', title, oldid, e.stack);
134138
}
135139
});
136140
yield async.eachLimit(articles, maxConcurrency, dumpArticleFn, resume());

0 commit comments

Comments
 (0)