Added defensive logic to File Indexer for scenarios where file does not exist on disk. Added ability to reset the search index prior to reindexing.
This commit is contained in:
@ -45,10 +45,25 @@ namespace Oqtane.Modules.Admin.Files.Manager
|
||||
var path = folder.Path + file.Name;
|
||||
|
||||
var body = "";
|
||||
if (DocumentExtensions.Contains(Path.GetExtension(file.Name)))
|
||||
if (System.IO.File.Exists(_fileRepository.GetFilePath(file)))
|
||||
{
|
||||
// get the contents of the file
|
||||
body = System.IO.File.ReadAllText(_fileRepository.GetFilePath(file));
|
||||
// only non-binary files can be indexed
|
||||
if (DocumentExtensions.Contains(Path.GetExtension(file.Name)))
|
||||
{
|
||||
// get the contents of the file
|
||||
try
|
||||
{
|
||||
body = System.IO.File.ReadAllText(_fileRepository.GetFilePath(file));
|
||||
}
|
||||
catch
|
||||
{
|
||||
// could not read the file
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
removed = true; // file does not exist on disk
|
||||
}
|
||||
|
||||
var searchContent = new SearchContent
|
||||
|
Reference in New Issue
Block a user