Merge pull request #2824 from thelounge/xpaw/fix-storage-deref

Fix stored image previews not being dereferenced
This commit is contained in:
Jérémie Astori 2018-10-06 01:39:25 -04:00 committed by GitHub
commit 79801af219
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,17 +84,25 @@ Chan.prototype.pushMessage = function(client, msg, increasesUnread) {
// If maxHistory is 0, image would be dereferenced before client had a chance to retrieve it, // If maxHistory is 0, image would be dereferenced before client had a chance to retrieve it,
// so for now, just don't implement dereferencing for this edge case. // so for now, just don't implement dereferencing for this edge case.
if (Helper.config.prefetch && Helper.config.prefetchStorage && Helper.config.maxHistory > 0) { if (Helper.config.maxHistory > 0) {
this.dereferencePreviews(deleted); this.dereferencePreviews(deleted);
} }
} }
}; };
Chan.prototype.dereferencePreviews = function(messages) { Chan.prototype.dereferencePreviews = function(messages) {
if (!Helper.config.prefetch || !Helper.config.prefetchStorage) {
return;
}
messages.forEach((message) => { messages.forEach((message) => {
if (message.preview && message.preview.thumb) { if (message.previews) {
storage.dereference(message.preview.thumb); message.previews.forEach((preview) => {
message.preview.thumb = null; if (preview.thumb) {
storage.dereference(preview.thumb);
preview.thumb = null;
}
});
} }
}); });
}; };