ZF-2448: Zend_Search_Lucene fix [ZF-1729] causes new corruption issues

Description

From the original bug report (taken via e-mail):

This message might concern you if you are using Zend_Search_Lucene from SVN since revision 7368 inclusive (January 09, 2008).

I believe I have discovered a new bug that has been introduced to Zend_Search_Lucene_Index_Writer (Revsion #7368 / Reference: ZF-1729)

Under certain conditions, the bug produces a Zend_Search_Lucene_Exception with message such as 'File './my_data_directory/_781_1.del' is not readable.' The precise filename (_781_1.del in the above example) obviously varies. Navigating to the data directory I see that indeed the file _781_1.del does not exist, however, the file _781_1_a.del usually does exist!

The bug goes away if I revert Zend_Search_Lucene_Index_Writer to the previous revision (Revsion # 6564) so something definitely in the last change is causing the bug.

Comments

Fixed.

The problem wasn't actually caused by [ZF-1729] fix. It was made early, but only improved folder cleaning-up helped to find it out.