mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-02-04 08:03:53 +01:00
[automation] ScriptFileWatcher Initial import now only processes dir (#2708)
Signed-off-by: Jonathan Gilbert <jpg@trillica.com>
This commit is contained in:
parent
a4c39d5ba0
commit
290ad08107
@ -128,6 +128,24 @@ public class ScriptFileWatcher extends AbstractWatchService implements ReadyServ
|
|||||||
this.executorFactory = executorFactory;
|
this.executorFactory = executorFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes initial import of resources.
|
||||||
|
*
|
||||||
|
* @param rootDirectory the root directory to import initial resources from
|
||||||
|
*/
|
||||||
|
private void importInitialResources(File rootDirectory) {
|
||||||
|
if (rootDirectory.exists()) {
|
||||||
|
File[] files = rootDirectory.listFiles();
|
||||||
|
if (files != null) {
|
||||||
|
for (File f : files) {
|
||||||
|
if (!f.isHidden()) {
|
||||||
|
importResources(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Imports resources from the specified file or directory.
|
* Imports resources from the specified file or directory.
|
||||||
*
|
*
|
||||||
@ -285,7 +303,7 @@ public class ScriptFileWatcher extends AbstractWatchService implements ReadyServ
|
|||||||
if (newLevel >= StartLevelService.STARTLEVEL_MODEL) { // start
|
if (newLevel >= StartLevelService.STARTLEVEL_MODEL) { // start
|
||||||
ScheduledExecutorService localScheduler = executorFactory.get();
|
ScheduledExecutorService localScheduler = executorFactory.get();
|
||||||
scheduler = localScheduler;
|
scheduler = localScheduler;
|
||||||
localScheduler.submit(() -> importResources(new File(pathToWatch)));
|
localScheduler.submit(() -> importInitialResources(new File(pathToWatch)));
|
||||||
localScheduler.scheduleWithFixedDelay(() -> checkFiles(currentStartLevel), 0, RECHECK_INTERVAL,
|
localScheduler.scheduleWithFixedDelay(() -> checkFiles(currentStartLevel), 0, RECHECK_INTERVAL,
|
||||||
TimeUnit.SECONDS);
|
TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user