Resurrect posts in case of false-positives. #932

This commit is contained in:
Nicolas Stepien 2013-03-13 21:42:09 +01:00
parent ae970c678a
commit 968cb9744b
3 changed files with 47 additions and 6 deletions

View File

@ -5748,11 +5748,10 @@
_ref = ThreadUpdater.thread.posts;
for (ID in _ref) {
post = _ref[ID];
if (post.isDead) {
continue;
}
ID = +ID;
if (__indexOf.call(index, ID) < 0) {
if (post.isDead && __indexOf.call(index, ID) >= 0) {
post.resurrect();
} else if (__indexOf.call(index, ID) < 0) {
post.kill();
deletedPosts.push(post);
} else if (post.file && !post.file.isDead && __indexOf.call(files, ID) < 0) {
@ -7345,6 +7344,28 @@
}
};
Post.prototype.resurrect = function() {
var clone, strong, _i, _len, _ref, _results;
delete this.isDead;
delete this.timeOfDeath;
$.rmClass(this.nodes.root, 'deleted-post');
strong = $('strong.warning', this.nodes.info);
if (this.file && this.file.isDead) {
strong.textContent = '[File deleted]';
} else {
$.rm(strong);
}
if (this.isClone) {
_ref = this.clones;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
clone = _ref[_i];
_results.push(clone.resurrect());
}
return _results;
}
};
Post.prototype.addClone = function(context) {
return new Clone(this, context);
};

View File

@ -3941,9 +3941,13 @@ ThreadUpdater =
deletedFiles = []
# Check for deleted posts/files.
for ID, post of ThreadUpdater.thread.posts
continue if post.isDead
# XXX tmp fix for 4chan's racing condition
# giving us false-positive dead posts.
# continue if post.isDead
ID = +ID
unless ID in index
if post.isDead and ID in index
post.resurrect()
else unless ID in index
post.kill()
deletedPosts.push post
else if post.file and !post.file.isDead and ID not in files

View File

@ -185,6 +185,22 @@ class Post
$.add quotelink, $.tn '\u00A0(Dead)'
$.addClass quotelink, 'deadlink'
return
# XXX tmp fix for 4chan's racing condition
# giving us false-positive dead posts.
resurrect: ->
delete @isDead
delete @timeOfDeath
$.rmClass @nodes.root, 'deleted-post'
strong = $ 'strong.warning', @nodes.info
# no false-positive files
if @file and @file.isDead
strong.textContent = '[File deleted]'
else
$.rm strong
return if @isClone
for clone in @clones
clone.resurrect()
return
addClone: (context) ->
new Clone @, context
rmClone: (index) ->