Skip to content

Commit

Permalink
Intento de fix para #11
Browse files Browse the repository at this point in the history
  • Loading branch information
iglosiggio committed Jun 15, 2017
1 parent b8d4273 commit ca7bc79
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions debian_packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ var format = utils.format_map;
var regex_fold = utils.regex_fold;
var get_field = utils.get_field;

/* Intervalo en el que node hace polling de los archivos, mínimo 5007 y máximo ~5 segundos antes del LOAD_INTERVAL */
var watchFile_interval = Math.max(LOAD_INTERVAL - 5007, 5007);

/* Diccionario para parsear fields específicos */
var FIELD = {};

Expand All @@ -23,18 +26,20 @@ function init_parser(files) {
var distro_match = distro_regex.exec(filename);
var distro = distro_match && distro_match[1] ? distro_match[1] : 'unknown';

function mark_dirty(event) {
function mark_dirty(stats_now, last_stats) {
var usable_filename = filename.replace(config.REPO_DISTS_DIR, '');

debug('Evento en [%s] (%s)', usable_filename, event);
if(stats_now.mtimeMs != last_stats.mtimeMs) {
debug('Se modificó [%s]', usable_filename);

repo.dirty = true;
repo.dirty = true;
}
}

filewatch = {
filename: filename,
distro: distro,
watch: fs.watch(filename, mark_dirty)
watch: fs.watchFile(filename, { interval: watchFile_interval }, mark_dirty)
};

return filewatch;
Expand Down

0 comments on commit ca7bc79

Please sign in to comment.