IndexDatabase.java revision 1393
207N/A * See LICENSE.txt included in this distribution for the specific
207N/A * file and include the License file at LICENSE.txt.
207N/Apublic class IndexDatabase {
207N/A private boolean interrupted;
207N/A initialize();
312N/A static void updateAll(ExecutorService executor, IndexChangedListener listener) throws IOException {
668N/A public static void update(ExecutorService executor, IndexChangedListener listener, List<String> paths) throws IOException {
668N/A } catch (IOException e) {
580N/A throw new FileNotFoundException("Failed to create root directory [" + indexDir.getAbsolutePath() + "]");
580N/A throw new FileNotFoundException("Failed to create root directory [" + spellDir.getAbsolutePath() + "]");
359N/A interrupted = false;
816N/A //TODO we might need to add writer.commit after certain phases of index generation, right now it will only happen in the end
1112N/A //TODO below should be optional, since it traverses the tree once more to get total count! :(
457N/A while (uidIter.term() != null && uidIter.term().field().equals("u") && uidIter.term().text().startsWith(startuid)) {
457N/A removeFile();
207N/A } catch (IOException e) {
656N/A } catch (IOException e) {
1054N/A log.log(Level.WARNING, "Failed to set last modified time on ''{0}'', used for timestamping the index database.", timestamp.getAbsolutePath());
1054N/A log.log(Level.WARNING, "Failed to create file ''{0}'', used for timestamping the index database.", timestamp.getAbsolutePath());
207N/A } catch (IOException e) {
207N/A } catch (IOException e) {
207N/A public void createSpellingSuggestions() {
207N/A } catch (IOException e) {
207N/A } catch (IOException e) {
359N/A } catch (IOException e) {
1054N/A log.log(Level.INFO, "Failed to remove obsolete xref-file: {0}", xrefFile.getAbsolutePath());
1054N/A log.log(Level.FINE, "Skipped symlink ''{0}'' -> ''{1}''", new Object[]{absolutePath, canonicalPath});
876N/A //below will only let go files and directories, anything else is considered special and is not added
1016N/A private boolean acceptSymlink(String absolutePath, String canonicalPath) throws IOException {
1016N/A absolutePath.substring(allowedSymlink.length()).equals(canonicalPath.substring(allowedTarget.length()))) {
1108N/A private int indexDown(File dir, String parent, boolean count_only, int cur_count, int est_total) throws IOException {
359N/A if (isInterrupted()) {
1112N/A return lcur_count;
1112N/A return lcur_count;
1112N/A return lcur_count;
1112N/A if (count_only) {
1114N/A if (RuntimeEnvironment.getInstance().isPrintProgress() && est_total > 0 && log.isLoggable(Level.INFO) )
1190N/A log.log(Level.INFO, "Progress: {0} ({1}%)", new Object[]{lcur_count, (lcur_count * 100.0f / est_total) });
1185N/A String uid = Util.path2uid(path, DateTools.timeToString(file.lastModified(), DateTools.Resolution.MILLISECOND)); // construct uid for doc
207N/A removeFile();
1112N/A return lcur_count;
359N/A interrupted = true;
359N/A private boolean isInterrupted() {
359N/A return interrupted;
459N/A } catch (IOException e) {
459N/A } catch (IOException e) {
459N/A } catch (IOException e) {
459N/A } catch (IOException e) {