fixed a bug with .newGID(..)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-11-14 20:51:22 +03:00
parent d727691977
commit 73b52b347c
3 changed files with 19 additions and 7 deletions

View File

@ -308,20 +308,28 @@ var DataPrototype = {
//
// If no arguments are given then a unique gid will be generated.
//
// XXX revise...
newGid: function(str, nohash){
var p = location.hostname + '-'
// prevent same gids from ever being created...
// NOTE: this is here in case we are generating new gids fast
// enough that Date.now() produces identical results for 2+
// consecutive calls...
var t = module.__gid_ticker = (module.__gid_ticker || 0) + 1
var p = typeof(location) != 'undefined' ? location.hostname : ''
// if we are on node.js add process pid
if(typeof(process) != 'undefined'){
p += process.pid + '-'
p += process.pid
}
// return string as-is...
if(nohash){
return str || p+Date.now()
return str || p+'-'+t+'-'+Date.now()
}
// make a hash...
var gid = hash(str || (p+Date.now()))
var gid = hash(str || (p+'-'+t+'-'+Date.now()))
// for explicit string return the hash as-is...
if(str != null){
@ -331,7 +339,7 @@ var DataPrototype = {
// check that the gid is unique...
while(this.ribbon_order.indexOf(gid) >= 0
|| this.order.indexOf(gid) >= 0){
gid = hash(p+Date.now())
gid = hash(p+'-'+t+'-'+Date.now())
}
return gid

View File

@ -44,7 +44,7 @@ function(data, cmp){
res.data.current = data.position
// ribbons and images...
$.each(data.ribbons, function(i, input_images){
data.ribbons.forEach(function(input_images, i){
var ribbon = []
ribbons.push(ribbon)
for(var id in input_images){

View File

@ -2906,9 +2906,13 @@ var FileSystemLoaderActions = actions.Actions({
loadPath: ['File/',
function(path){
var that = this
// XXX does not appear to load correctly...
// XXX this will not work for explicit path (path to a dir
// that contains the index)
file.loadIndex(path)
.done(function(res){
// XXX if res is empty load raw...
// XXX res may contain multiple indexes, need to
// combine them...
var k = Object.keys(res)[0]