Пример #1
0
        /// <summary>Removes an existing file in the directory. </summary>
        public override void DeleteFile(string name)
        {
            _realDirectory.DeleteFile(name);

            //perform on both dirs
            if (Enabled)
            {
                _tempStorageDir.DeleteFile(name);
            }
        }
        ///<summary>
        /// Added safety check on last batch of additions for &lt; 3.0 based Lucene implementations
        /// <see cref="https://issues.apache.org/jira/browse/LUCENE-3255"/>
        ///</summary>
        ///<param name="dir">return true if OK false if a potentially corrupted segments file was removed</param>
        public static bool CheckLastCommitOk(FSDirectory dir)
        {
            string     latestSeg = SegmentInfos.GetCurrentSegmentFileName(dir);
            IndexInput input     = dir.OpenInput(latestSeg);
            int        format    = input.ReadInt();

            input.Close();
            if (format != SegmentInfos.FORMAT_DIAGNOSTICS)
            {
                dir.DeleteFile(latestSeg);
                return(false);
            }
            return(true);
        }