Esempio n. 1
0
proto.filterFiles = function(filelist, groups, relativePath, indexStr)
{
	if (!groups || !groups.length || !groups[groups.length-1])
	{
		throw new Error('NO FILE INDEX,'+indexStr);
	}

	var requestMaxIndex = ClientKey.parse.maxIndexInGroup(groups);

	debug('[%s]global len:%d group:%o, max index:%d, file lenth:%d',
		indexStr, groups.length, groups, requestMaxIndex, filelist.length);

	if (requestMaxIndex > filelist.length)
	{
		throw new Error('INDEX OVERFLOW,'+indexStr);
	}

	var indexs = ClientKey.parse.groups2indexs(groups);
	var result = indexs.map(function(index)
		{
			var file = relativePath+filelist[index];
			file = path.normalize(file);

			if (isOverflowPath(file)) throw new Error('FILE PATH OVERFLOW,'+file);
			return file;
		});

	debug('[%s] result len:%d indexs:%o list:%o', indexStr, result.length, indexs, result);

	return result;
}
Esempio n. 2
0
proto.parseFileArray = function(data)
{
	try {
		return Promise.resolve(ClientKey.parse.str2groups(data))
	}
	catch(err)
	{
		return Promise.reject(err);
	}
};