1212
1313import static com .google .common .collect .Sets .newConcurrentHashSet ;
1414import static java .nio .file .Files .exists ;
15+ import static org .eclipse .che .api .vfs .watcher .FileWatcherUtils .toInternalPath ;
1516
1617import com .google .inject .Inject ;
18+ import java .io .File ;
1719import java .nio .file .Path ;
1820import java .nio .file .PathMatcher ;
1921import java .util .Iterator ;
2325import java .util .concurrent .ConcurrentHashMap ;
2426import java .util .concurrent .atomic .AtomicInteger ;
2527import java .util .function .Consumer ;
28+ import javax .inject .Named ;
2629import javax .inject .Singleton ;
2730import org .slf4j .Logger ;
2831import org .slf4j .LoggerFactory ;
@@ -44,8 +47,12 @@ public class FileWatcherByPathMatcher implements Consumer<Path> {
4447 /** Registered path -> Path watch operation IDs */
4548 private final Map <Path , Set <Integer >> pathWatchRegistrations = new ConcurrentHashMap <>();
4649
50+ private final File root ;
51+
4752 @ Inject
48- public FileWatcherByPathMatcher (FileWatcherByPathValue watcher ) {
53+ public FileWatcherByPathMatcher (
54+ @ Named ("che.user.workspaces.storage" ) File root , FileWatcherByPathValue watcher ) {
55+ this .root = root ;
4956 this .watcher = watcher ;
5057 }
5158
@@ -57,6 +64,7 @@ public void accept(Path path) {
5764 }
5865 paths .values ().forEach (it -> it .remove (path ));
5966 paths .entrySet ().removeIf (it -> it .getValue ().isEmpty ());
67+ return ;
6068 }
6169
6270 for (PathMatcher matcher : matchers .keySet ()) {
@@ -74,6 +82,7 @@ public void accept(Path path) {
7482 watcher .watch (path , operation .create , operation .modify , operation .delete );
7583 pathWatchRegistrations .putIfAbsent (path , newConcurrentHashSet ());
7684 pathWatchRegistrations .get (path ).add (pathWatcherOperationId );
85+ operation .create .accept (toInternalPath (root .toPath (), path ));
7786 }
7887 }
7988 }
0 commit comments