GetLastWriteTimeUtc() public static method

public static GetLastWriteTimeUtc ( string path ) : System.DateTime
path string
return System.DateTime
Ejemplo n.º 1
0
 private void OnIndexModifierFinishedIndexOperation(object sender, FinishedIndexOperationEventArgs e)
 {
     if (e.Operation.Action == IndexOperation.OptimizeIndex)
     {
         this._indexModifier.FinishedIndexOperation -= OnIndexModifierFinishedIndexOperation;
         this._settings.LastIndexOptimization        = Directory.GetLastWriteTimeUtc(this._settings.IndexPath);
     }
 }
Ejemplo n.º 2
0
 public static DateTime GetLastWriteTimeUtc(string path)
 {
     if (_provider == null)
     {
         return(Directory.GetLastWriteTimeUtc(path));
     }
     return(_provider.GetLastWriteTimeUtc(path));
 }
Ejemplo n.º 3
0
    /// <summary>
    ///     Gets a specific directory's last write time, in UTC.
    /// </summary>
    /// <param name="path">The path of the directory.</param>
    /// <returns>
    ///     A <see cref="DateTime" /> in UTC.
    /// </returns>
    /// <exception cref="ArgumentNullException">
    ///     <paramref name="path" /> is <see langword="null" /> (<see langword="Nothing" />
    ///     in Visual Basic).
    /// </exception>
    public DateTime GetLastWriteTime(string path)
    {
        _ = Requires.NotNullOrWhiteSpace(
            path,
            nameof(path));

        return(FSDir.GetLastWriteTimeUtc(path));
    }
Ejemplo n.º 4
0
 public static System.DateTime GetLastWriteTimeUtc(string path) =>
 MSIOD.GetLastWriteTimeUtc(path);
Ejemplo n.º 5
0
 public override DateTimeOffset GetLastWriteTime()
 => new DateTimeOffset(D.GetLastWriteTimeUtc(this.FullName), TimeSpan.Zero);
Ejemplo n.º 6
0
        /// <summary>
        /// Checks the index. If it does not exists, this will start
        /// creating a new index. This process is recoverable/restartable and
        /// can/should be called each time the Search is expected to be used.
        /// </summary>
        /// <param name="force">if set to <c>true</c> a re-indexing of all
        /// items is started.</param>
        public void CheckIndex(bool force)
        {
            if (!UseIndex)
            {
                return;
            }

            bool restartIndexing = false;
            bool fileBasedIndex  = this._settings.IndexPath != null &&
                                   Directory.Exists(this._settings.IndexPath);
            string   indexingStateFile = this.RestartIndexingStateFile;
            DateTime indexModifiedAt   = DateTime.MinValue;

            if (fileBasedIndex)
            {
                indexModifiedAt = Directory.GetLastWriteTimeUtc(this._settings.IndexPath);
                bool indexStateFileExists = (indexingStateFile != null && File.Exists(indexingStateFile));

                // if the index have to be (re-)created, we don't want to rely on old restart infos:
                if ((force || startIndexAll) && indexStateFileExists)
                {
                    FileHelper.Delete(indexingStateFile);
                }
                // restart indexing: read state and go on with the next non-indexed feed
                restartIndexing = (!startIndexAll && indexStateFileExists);
            }
            else
            {
                startIndexAll = true;
            }

            if (force || restartIndexing || startIndexAll)
            {
                IDictionary     restartInfo = null;
                DictionaryEntry lastIndexed = new DictionaryEntry();
                if (restartIndexing)
                {
                    // read indexState into restartInfo (persisted feed urls/id, that are yet indexed)
                    restartInfo = ReadIndexingRestartStateFileContent(indexingStateFile, out lastIndexed);
                }
                if (restartInfo == null)
                {
                    restartInfo = new HybridDictionary();
                }

                if (startIndexAll)
                {
                    this._indexModifier.CreateIndex();
                }

                LuceneIndexer indexer = GetIndexer();
                indexer.IndexingFinished += OnIndexingFinished;
                indexer.IndexingProgress += OnIndexingProgress;
                indexer.IndexAll(restartInfo, lastIndexed);
            }
            else if (fileBasedIndex)
            {
                // check, if we have to call OptimizeIndex():
                DateTime lastIndexModification = this._settings.LastIndexOptimization;
                int      compareResult         = indexModifiedAt.CompareTo(lastIndexModification);
                // indexModifiedAt is greater than lastIndexModification, hence index was modified:
                if (compareResult > 0)
                {
                    // attach event to get optimize index finished notification:
                    this._indexModifier.FinishedIndexOperation += OnIndexModifierFinishedIndexOperation;
                    this.IndexOptimize();
                }
                else if (compareResult != 0)
                {
                    // correct the bad persisted entry:
                    this._settings.LastIndexOptimization = Directory.GetLastWriteTimeUtc(this._settings.IndexPath);
                }
            }
        }
Ejemplo n.º 7
0
 public override DateTime GetLastWriteTimeUtc(string path)
 {
     return(Directory.GetLastWriteTimeUtc(path));
 }