castor-load
Advanced tools
Comparing version 1.0.1 to 1.1.1
@@ -18,4 +18,3 @@ 'use strict'; | ||
} | ||
var self = this, | ||
now = new Date(); | ||
var self = this; | ||
@@ -51,3 +50,2 @@ assert.equal(typeof pathname, 'string'); | ||
self.doc.dateLoaded = now; | ||
self.doc.dateCreated = stats.ctime || null; | ||
@@ -62,3 +60,3 @@ self.doc.dateModified = stats.mtime || null; | ||
if (self.doc.sha1 || self.doc.type !== 'file') { | ||
if (self.doc.sha1 || self.doc.filetype !== 'file') { | ||
return fn(null, self.doc); | ||
@@ -65,0 +63,0 @@ } |
@@ -41,2 +41,3 @@ 'use strict'; | ||
self.options.directory = self.directory; // for tingodb | ||
self.options.dateConfig = options.dateConfig || null; | ||
if (!Array.isArray(self.options.ignore)) { | ||
@@ -48,5 +49,5 @@ self.options.ignore = []; | ||
} | ||
self.basedoc = { | ||
dateChecked: new Date(), | ||
dateConfig : self.options.dateConfig, | ||
dateLoaded : new Date(), | ||
basedir: self.directory | ||
@@ -90,6 +91,7 @@ }; | ||
ignored: function(s) { return self.ignore(s); } | ||
, ignoreInitial : true | ||
, persistent: true | ||
} | ||
); | ||
debug('Watcher is started'); | ||
watcher | ||
@@ -133,2 +135,9 @@ .on('add', function(path, stats) { | ||
var self = this, i = 0, o = 0; | ||
function conclude(o) { | ||
done(o); | ||
process.nextTick(function() { | ||
self.emit('watching'); | ||
self.watch(); | ||
}); | ||
} | ||
var findr = findit(self.directory); | ||
@@ -145,3 +154,3 @@ findr.on('directory', function (dir, stats, stop) { | ||
if (i === o) { | ||
done(o); | ||
conclude(o); | ||
} | ||
@@ -158,3 +167,3 @@ }); | ||
if (i === o) { | ||
done(o); | ||
conclude(o); | ||
} | ||
@@ -175,3 +184,3 @@ }); | ||
if (i === o) { | ||
done(o); | ||
conclude(o); | ||
} | ||
@@ -188,3 +197,3 @@ }); | ||
if (i === o) { | ||
done(o); | ||
conclude(o); | ||
} | ||
@@ -196,7 +205,2 @@ }); | ||
); | ||
findr.on('end', function () { | ||
self.emit('watching'); | ||
self.watch(); | ||
} | ||
) | ||
} | ||
@@ -203,0 +207,0 @@ |
@@ -32,2 +32,3 @@ 'use strict'; | ||
self.options.delay = options.delay || 1000; | ||
self.options.synckey = options.synckey || null; | ||
self.dateSynchronised = new Date(); | ||
@@ -333,6 +334,13 @@ self.mountor = mountor; | ||
var self = this; | ||
var d1 = new Date(doc.dateModified), d2 = new Date(d.dateModified); | ||
if (d.dateModified && d.dateModified.getTime() === doc.dateModified.getTime()) { | ||
debug('unchange', doc.fid); | ||
if ( ( | ||
d.dateModified && doc.dateModified && d.dateModified.getTime() === doc.dateModified.getTime() | ||
) | ||
&& | ||
( | ||
! doc.dateConfig || ( | ||
d.dateConfig && doc.dateConfig && d.dateConfig.getTime() === doc.dateConfig.getTime() | ||
) | ||
) ) { | ||
debug('unchange', doc.fid); | ||
next(); | ||
@@ -359,3 +367,2 @@ } | ||
} | ||
if (logicalSHA1 && logicalSHA1 !== physicalSHA1) { | ||
@@ -369,3 +376,5 @@ debug('updated', physical.filename); | ||
physical.state = 'updated'; | ||
self.update(logical.fid, physical, next); | ||
var newdoc = {}; | ||
extend(true, newdoc, logical, physical); | ||
self.update(logical.fid, newdoc, next); | ||
} | ||
@@ -372,0 +381,0 @@ } |
{ | ||
"name": "castor-load", | ||
"version": "1.0.1", | ||
"version": "1.1.1", | ||
"author": "Nicolas Thouvenin <nthouvenin@gmail.com>", | ||
@@ -5,0 +5,0 @@ "contributors": [], |
37957
1086