Skip to content

Commit 9fb5a5f

Browse files
committed
Rebuilding the index when there is an empty file value #8
1 parent ca888e5 commit 9fb5a5f

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/UmbracoExamine.PDF/PDFIndexer.cs

+22-17
Original file line numberDiff line numberDiff line change
@@ -172,29 +172,34 @@ protected override Dictionary<string, string> GetDataToIndex(XElement node, stri
172172
{
173173
filePath = JObject.Parse(filePath).Value<string>("src");
174174
}
175-
// Get the file path from the data service
176-
string fullPath = this.DataService.MapPath(filePath);
177-
var fi = new FileInfo(fullPath);
178-
if( fi.Exists)
175+
176+
if (!filePath.IsNullOrWhiteSpace())
179177
{
180-
try
181-
{
182-
fields.Add(TextContentFieldName, ExtractTextFromFile(fi));
183-
}
184-
catch (NotSupportedException)
178+
// Get the file path from the data service
179+
string fullPath = this.DataService.MapPath(filePath);
180+
var fi = new FileInfo(fullPath);
181+
if (fi.Exists)
185182
{
186-
//log that we couldn't index the file found
187-
DataService.LogService.AddErrorLog((int) node.Attribute("id"), "UmbracoExamine.FileIndexer: Extension '" + fi.Extension + "' is not supported at this time");
183+
try
184+
{
185+
fields.Add(TextContentFieldName, ExtractTextFromFile(fi));
186+
}
187+
catch (NotSupportedException)
188+
{
189+
//log that we couldn't index the file found
190+
DataService.LogService.AddErrorLog((int)node.Attribute("id"), "UmbracoExamine.FileIndexer: Extension '" + fi.Extension + "' is not supported at this time");
191+
}
192+
catch (Exception ex)
193+
{
194+
DataService.LogService.AddErrorLog((int)node.Attribute("id"), "An error occurred: " + ex);
195+
}
188196
}
189-
catch (Exception ex)
197+
else
190198
{
191-
DataService.LogService.AddErrorLog((int)node.Attribute("id"), "An error occurred: " + ex);
199+
DataService.LogService.AddInfoLog((int)node.Attribute("id"), "UmbracoExamine.FileIndexer: No file found at path " + filePath);
192200
}
193201
}
194-
else
195-
{
196-
DataService.LogService.AddInfoLog((int)node.Attribute("id"), "UmbracoExamine.FileIndexer: No file found at path " + filePath);
197-
}
202+
198203
}
199204

200205
return fields;

0 commit comments

Comments
 (0)