Beispiel #1
0
        private bool IsFileContentsUpToDate(FileSystemEntities entities, FullPathChanges fullPathChanges, FileWithContents existingFileWithContents)
        {
            Debug.Assert(existingFileWithContents.Contents != null);

            var fullPath = existingFileWithContents.FileName.FullPath;

            if (fullPathChanges != null)
            {
                // We don't get file change events for file in symlinks, so we can't
                // rely on fullPathChanges contents for our heuristic of avoiding file
                // system access.
                if (!FileDatabaseSnapshot.IsContainedInSymLinkHelper(entities.Directories, existingFileWithContents.FileName))
                {
                    return(fullPathChanges.ShouldSkipLoadFileContents(fullPath));
                }
            }

            // Do the "expensive" check by going to the file system.
            var fi = _fileSystem.GetFileInfoSnapshot(fullPath);

            return
                ((fi.Exists) &&
                 (fi.IsFile) &&
                 (fi.LastWriteTimeUtc == existingFileWithContents.Contents.UtcLastModified));
        }
Beispiel #2
0
 /// <summary>
 /// Note: Concurrency: There are potentially many readers (search threads), but
 /// only one writer (us). Updating the hash table with the line below assumes
 /// that 1) the entry exists and 2) the hash table implementation does not
 /// mutate any of its internal state when updating an existing entry.
 /// <para>
 /// 1) is verified because we the "filesToRead" collections only contains
 ///    file names contained in this table.</para>
 /// <para>
 /// 2) is verified because the two possible implementations, <see cref="Dictionary{TKey,TValue}"/>
 ///    and <see cref="SlimHashTable{TKey,TValue}"/> behave that way.</para>
 /// </summary>
 private static void DangerousUpdateFileTableEntry(FileDatabaseSnapshot fileDatabase,
                                                   FileName fileName,
                                                   FileContents newContents)
 {
     fileDatabase.Files[fileName] = new FileWithContents(fileName, newContents);
 }