Skip to content

Commit

Permalink
Merge pull request #226 from CertifaiAI/sh_empty_folder
Browse files Browse the repository at this point in the history
Sh empty folder
  • Loading branch information
codenamewei authored Nov 22, 2020
2 parents 5a73529 + 4c31fa0 commit 6b7b59c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import ai.classifai.ui.launcher.WelcomeLauncher;
import ai.classifai.util.ParamConfig;
import ai.classifai.util.ProjectHandler;
import ai.classifai.util.data.FileHandler;
import ai.classifai.util.data.ImageHandler;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -31,6 +32,7 @@
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*;
import java.io.File;
import java.util.ArrayList;

/**
* Open browser to select folder with importing list of data points in the folder
Expand Down Expand Up @@ -97,6 +99,7 @@ protected JDialog createDialog(Component parent)
loader.setFileSystemStatus(FileSystemStatus.WINDOW_CLOSE_LOADING_FILES);

ImageHandler.processFolder(projectID, rootFolder);

}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,19 @@ public static void processFile(@NonNull Integer projectID, @NonNull List<File> f
public static void processFolder(@NonNull Integer projectID, @NonNull File rootPath)
{
List<File> totalFilelist = new ArrayList<>();

Stack<File> folderStack = new Stack<>();
ProjectLoader loader = ProjectHandler.getProjectLoader(projectID);
String[] fileExtension = ImageFileType.getImageFileTypes();
java.util.List<File> checkFileFormat = FileHandler.processFolder(rootPath, fileExtension);

folderStack.push(rootPath);

if(checkFileFormat.isEmpty())
{
loader.reset(FileSystemStatus.WINDOW_CLOSE_DATABASE_NOT_UPDATED);
return;
}

while(folderStack.isEmpty() != true)
{
File currentFolderPath = folderStack.pop();
Expand All @@ -320,8 +328,9 @@ public static void processFolder(@NonNull Integer projectID, @NonNull File rootP
totalFilelist.addAll(files);
}
}

}

saveToDatabase(projectID, totalFilelist);
}
}
}

0 comments on commit 6b7b59c

Please sign in to comment.