Modify FileTailImpl so that it skips hidden directories (dirs with names 
beginning with ".").
---------------------------------------------------------------------------------------------

                 Key: PAXURL-76
                 URL: http://issues.ops4j.org/browse/PAXURL-76
             Project: Pax URL
          Issue Type: Improvement
          Components: dir
    Affects Versions: 1.1.2
            Reporter: Miroslav Pokorny
            Assignee: Alin Dreghiciu



Like most projects, my code also has dot something directories created by
subversion and its kin. When I have had logging on I have noticed that
FileTailImpl.java also traverses my .svn directories which is a waste.

   protected File findParentOfTail( File folder )
       throws IOException
   {
       logger.debug( "findParentOfTail " + folder.getAbsolutePath() );
       for( File f : folder.listFiles() )
       {   <<< ADD HIDDEN FILE TEST HERE >>>
           if( !f.isHidden() && f.isDirectory() )
           {
               File r = findParentOfTail( f );
               if( r != null )
               {
                   return r;
               }
           }
           else if( !f.isHidden() )
           {
               String p = f.getCanonicalPath().replaceAll( "\\\\", "/" );
               if( p.endsWith( m_tail ) )
               {
                   return new File(
                       f.getCanonicalPath().substring( 0,
f.getCanonicalPath().length() - m_tail.length() )
                   );
               }
           }
       }
       return null;
   }

I would suggest that an extra test be made on inside the loop to skip files
that begin with a "." as is the convention for "hidden" files.

if( f.getName().startsWith(".")){
  continue;
}

This would at the very least result in the time spent in FileTailImpl to be
cut in half or quarter due to the duplicate directories under .svn etc.

mP

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.ops4j.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

_______________________________________________
general mailing list
general@lists.ops4j.org
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to