From fab876e2e75381b84beaea94fbf0dc8b0f415c48 Mon Sep 17 00:00:00 2001 From: hns Date: Thu, 4 Jul 2002 18:31:11 +0000 Subject: [PATCH] Some cleanup, fixed bug where a zip file with entries for a prototype would prevent stuff in the prototype's directory to be ignored. (use getLastCheck() instead of getLastUpdate() to find out if we should look for new files in directory) --- src/helma/framework/core/TypeManager.java | 46 +++++++---------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/src/helma/framework/core/TypeManager.java b/src/helma/framework/core/TypeManager.java index 8151986a..4bc5f96a 100644 --- a/src/helma/framework/core/TypeManager.java +++ b/src/helma/framework/core/TypeManager.java @@ -23,7 +23,6 @@ public final class TypeManager { HashMap prototypes; HashMap zipfiles; long lastCheck = 0; - long idleSeconds = 120; // if idle for longer than 5 minutes, slow down boolean rewire; static String[] standardTypes = {"user", "global", "root", "hopobject"}; @@ -118,13 +117,12 @@ public final class TypeManager { zipped.update (); } } - + if (rewire) { // there have been changes in the DbMappings app.rewireDbMappings (); rewire = false; } - // app.logEvent (" ...done @ "+ (System.currentTimeMillis () - now)+ "--- "+idleSeconds); } @@ -152,11 +150,6 @@ public final class TypeManager { Prototype p = getPrototype (typename); if (p == null) { p = new Prototype (typename, app); - p.templates = new HashMap (); - p.functions = new HashMap (); - p.actions = new HashMap (); - p.skins = new HashMap (); - p.updatables = new HashMap (); prototypes.put (typename, p); } return p; @@ -170,26 +163,11 @@ public final class TypeManager { // System.err.println ("REGISTER PROTO: "+app.getName()+"/"+name); // app.logEvent ("registering prototype "+name); - // show the type checker thread that there has been type activity - idleSeconds = 0; - - HashMap ntemp = new HashMap (); - HashMap nfunc = new HashMap (); - HashMap nact = new HashMap (); - HashMap nskins = new HashMap (); - HashMap updatables = new HashMap (); - // Create and register type properties file File propfile = new File (dir, "type.properties"); SystemProperties props = new SystemProperties (propfile.getAbsolutePath ()); DbMapping dbmap = new DbMapping (app, name, props); - updatables.put ("type.properties", dbmap); - - proto.templates = ntemp; - proto.functions = nfunc; - proto.actions = nact; - proto.skins = nskins; - proto.updatables = updatables; + proto.updatables.put ("type.properties", dbmap); // app.scriptingEngine.updatePrototype (proto); } @@ -214,7 +192,8 @@ public final class TypeManager { boolean needsUpdate = false; HashSet updatables = null; - // our plan is to do as little as possible, so first check if anything has changed at all... + // our plan is to do as little as possible, so first check if + // anything the prototype knows about has changed on disk for (Iterator i = proto.updatables.values().iterator(); i.hasNext(); ) { Updatable upd = (Updatable) i.next(); if (upd.needsUpdate ()) { @@ -225,8 +204,14 @@ public final class TypeManager { } } - // check if file have been created since last update - if (proto.lastUpdate < dir.lastModified ()) { + // fetch previous last-check timestamp and update it on prototype + // we do this here for the (not very likely but possible) case + // where files are created in the exact moment we are doing this check. + long lastcheck = proto.getLastCheck (); + proto.markChecked (); + + // next we check if files have been created since last update + if (lastcheck < dir.lastModified ()) { String[] list = dir.list(); for (int i=0; i