if (whichOS.contains("Windows"))
dirName = dirName.replace('/','\\');
FileImporter importer = new FileImporter(logger, conn);
QDir dir = new QDir(dirName);
List<QFileInfo> list = dir.entryInfoList();
String notebook = conn.getWatchFolderTable().getNotebook(dirName);
for (int i=0; i<list.size(); i++){
logger.log(logger.LOW, "File found: " +list.get(i).fileName());
boolean redundant = false;
// Check if we've already imported this one or if it existed before
for (int j=0; j<importedFiles.size(); j++) {
logger.log(logger.LOW, "redundant file list: " +list.get(i).absoluteFilePath());
if (importedFiles.get(j).equals(list.get(i).absoluteFilePath()))
redundant = true;
}
logger.log(logger.LOW, "Checking if redundant: " +redundant);
if (!redundant) {
importer.setFileInfo(list.get(i));
importer.setFileName(list.get(i).absoluteFilePath());
logger.log(logger.LOW, "File importing is a file: " +list.get(i).isFile());
logger.log(logger.LOW, "File importing is a valid: " +importer.isValidType());
if (list.get(i).isFile() && importer.isValidType()) {
if (!importer.importFile()) {
// If we can't get to the file, it is probably locked. We'll try again later.
logger.log(logger.LOW, "Unable to save externally edited file. Saving for later.");
importFilesKeep.add(list.get(i).absoluteFilePath());
} else {
Note newNote = importer.getNote();
newNote.setNotebookGuid(notebook);
newNote.setTitle(dir.at(i));
NoteMetadata metadata = new NoteMetadata();
metadata.setDirty(true);
metadata.setGuid(newNote.getGuid());
listManager.addNote(newNote, metadata);
conn.getNoteTable().addNote(newNote, true);