private static boolean updateRoot()

in duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/indexing/DeferredCustomIndexer.java [254:303]


    private static boolean updateRoot(DeferredCustomIndexerFactory factory, URL root, FileObject rootFO, AtomicBoolean cancel) throws IOException {
        LOG.log(Level.FINE, "updating: {0}, for indexer: {1}", new Object[] {root.toExternalForm(), factory.getIndexerName()});
         File cacheRoot = cacheRoot(root, factory);
         FileObject deletedFile = FileUtil.toFileObject(new File(cacheRoot, "deleted"));
         Set<String> deletedFiles = deletedFile != null ? new HashSet<String>(deletedFile.asLines("UTF-8")) : Collections.<String>emptySet();

         FileObject modifiedFile = FileUtil.toFileObject(new File(cacheRoot, "modified"));
         Set<String> modifiedFiles = modifiedFile != null ? new HashSet<String>(modifiedFile.asLines("UTF-8")) : Collections.<String>emptySet();

         Set<FileObject> toIndex = new HashSet<FileObject>();

         for (String r : modifiedFiles) {
             FileObject f = rootFO.getFileObject(r);

             if (f != null) {
                 toIndex.add(f);
             }
         }

         if (!toIndex.isEmpty() || !modifiedFiles.isEmpty()) {
             factory.createIndexer().doIndex(new DeferredContext(root, rootFO, FileUtil.toFileObject(cacheRoot), toIndex, deletedFiles, cancel), new HashSet<FileObject>(toIndex), new HashSet<String>(deletedFiles));
         }

         boolean done = true;

         if (deletedFile != null) {
             if (deletedFiles.isEmpty()) {
                 deletedFile.delete();
             } else {
                 dump(new File(cacheRoot, "deleted"), deletedFiles);
                 done = false;
             }
         }
         if (modifiedFile != null) {
             if (toIndex.isEmpty()) {
                 modifiedFile.delete();
             }  else {
                 modifiedFiles.clear();

                 for (FileObject f : toIndex) {
                     modifiedFiles.add(FileUtil.getRelativePath(rootFO, f));
                 }

                 dump(new File(cacheRoot, "modified"), modifiedFiles);
                 done = false;
             }
         }

         return done;
    }