pike.git / lib / modules / Filesystem.pmod / Monitor.pmod / basic.pike

version» Context lines:

pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:1:   //   // Basic filesystem monitor.   // - // $Id: basic.pike,v 1.37 2010/04/27 14:58:11 grubba Exp $ + // $Id: basic.pike,v 1.38 2010/04/27 15:00:54 grubba Exp $   //   // 2009-07-09 Henrik Grubbström   //      //! Basic filesystem monitor.   //!   //! This module is intended to be used for incremental scanning of   //! a filesystem.      //! The default maximum number of seconds between checks of directories
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:294:    {    call_callback(global::stable_data_change, path, st);    }       protected string _sprintf(int c)    {    return sprintf("Monitor(%O, %O, next: %s, st: %O)",    path, flags, ctime(next_poll) - "\n", st);    }    +  //! Bump the monitor to an earlier scan time. +  //! +  //! @param seconds +  //! Number of seconds to bump. Defaults to @expr{30@}. +  void bump(int|void flags, int|void seconds) +  { +  next_poll -= seconds || 30; +  monitor_queue->adjust(this); +  +  if ((flags & MF_RECURSE) && st->isdir && files) { +  // Bump the files in the directory as well. +  foreach(files, string file) { +  file = canonic_path(Stdio.append_path(path, file)); +  Monitor m2 = monitors[file]; +  if (m2) { +  m2->bump(flags, seconds); +  } +  } +  } +  } +     //! Calculate and set a suitable time for the next poll of this monitor.    //!    //! @param st    //! New stat for the monitor.    //!    //! This function is called by @[check()] to schedule the    //! next check.    protected void update(Stdio.Stat st)    {    int delta = max_dir_check_interval || global::max_dir_check_interval;
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:401:    if (this_program::flags & MF_RECURSE) {    // The monitor for the file has probably removed itself,    // or the user has done it by hand, in either case we    // don't need to do anything more here.    } else if (!m2) {    file_deleted(file);    }    if (err) throw(err);    }    if (flags & MF_RECURSE) { -  // Check the remaining files in the directory. +  // Check the remaining files in the directory soon.    foreach(((files - new_files) - deleted_files), string file) {    file = canonic_path(Stdio.append_path(path, file));    Monitor m2 = monitors[file];    if (m2) { -  m2->check(flags); +  m2->bump(flags);    }    }    }    if (sizeof(new_files) || sizeof(deleted_files)) return 1;    } else {    attr_changed(path, st);    return 1;    }    return 0;    }
pike.git/lib/modules/Filesystem.pmod/Monitor.pmod/basic.pike:564:    return 1;    } else {    return 0;    }    if ((st->mtime != old_st->mtime) || (st->ctime != old_st->ctime) ||    (st->size != old_st->size)) {    last_change = time(1);    if (status_change(old_st, st, orig_flags, flags)) return 1;    }    if ((flags & MF_RECURSE) && (st->isdir)) { -  // Check the files in the directory. +  // Check the files in the directory soon.    foreach(files, string file) {    file = canonic_path(Stdio.append_path(path, file));    Monitor m2 = monitors[file];    if (m2) { -  m2->check(flags); +  m2->bump(flags);    }    }    }    if (last_change < time(1) - (stable_time || global::stable_time)) {    last_change = 0x7fffffff;    stable_data_change(path, st);    return 1;    }    return 0;    }