Skip to content

Commit 037dfe6

Browse files
committed
Add Cleaning of orphaned file entries
- Files that have already been used for training can now be deleted from the training folders and the database can be cleaned of those entries.
1 parent e35e1eb commit 037dfe6

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/imgclass.net/Service.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,21 @@ protected void SortImages(List<FileEntry> files)
237237

238238
protected void LoadFilesAndBuildGroups(string basePath, double ratio)
239239
{
240+
MyLog("Cleaning orphaned file entries...");
241+
foreach (var key in _files.Keys)
242+
{
243+
int orphanCount = 0;
244+
for (var i = _files[key].Count - 1; i >= 0; i--)
245+
{
246+
if (!File.Exists(_files[key][i].fn))
247+
{
248+
_files[key].RemoveAt(i);
249+
orphanCount++;
250+
}
251+
}
252+
if (orphanCount > 0) MyLog($"{key}: removed {orphanCount} orphaned entries");
253+
}
254+
240255
MyLog("Reading new files...");
241256
foreach (var path in Directory.GetDirectories(basePath))
242257
{

0 commit comments

Comments
 (0)