////////////////////////////////////////////////////////////////////////////////
// Thumbnails
//
// Manages cached thumbnails
////////////////////////////////////////////////////////////////////////////////
/*global require, exports, console */
var	$crypto = require('crypto'),
		entity = require('../db/media').media,
		processes = require('../logic/processes').processes,
		queue = require('../utils/queue').queue,
		
thumbs = function () {	
	var media = entity(),
	
	self = {
		// generates thumbnails for video files
		// identified by their mediaid's
		// - mediaids: array of media ids to generate thumbnail for
		// - force: when set, extraction doesn't check hash
		generate: function (mediaids, force, handler) {
			media.multiGet(mediaids, function (data) {
				var elems = [],
						i, entry,
						shasum;

				// generating hashes and collecting process input
				for (i = 0; i < data.length; i++) {
					entry = data[i];
					if (! entry.hash || force) {
						shasum = $crypto.createHash('md5');
						shasum.update(entry.path);
						entry.hash = shasum.digest('hex');
						elems.push(entry.rootid + '|' + entry.mediaid + '|' + entry.root + '|' + entry.path + '|' + entry.hash);
					}
				}
				
				// ending request
				if (typeof handler === 'function') {
					handler();
				}

				// passing elems to thumbnail extraction process
				if (elems.length) {
					processes.thumbnails
						.bump(elems)
						.start(true);
				}
			});
		}
	};
	
	return self;
}();

// exports
exports.thumbs = thumbs;


@@ -929,16 +929,62 @@
 ata%5Bi%5D;%0A
+%09%09%09%09%09if (typeof entry.path != 'undefined') %7B%0A%09
 %09%09%09%09%09if 
@@ -1005,24 +1005,25 @@
 %7C%7C force) %7B%0A
+%09
 %09%09%09%09%09%09shasum
@@ -1048,24 +1048,25 @@
 ash('md5');%0A
+%09
 %09%09%09%09%09%09shasum
@@ -1088,24 +1088,25 @@
 ath);%0A%09%09%09%09%09%09
+%09
 entry.hash =
@@ -1124,24 +1124,25 @@
 est('hex');%0A
+%09
 %09%09%09%09%09%09elems.
@@ -1236,24 +1236,32 @@
 ntry.hash);%0A
+%09%09%09%09%09%09%7D%0A
 %09%09%09%09%09%7D%0A%09%09%09%09%7D

Update thumbs.js