add skip process image when in known
This commit is contained in:
parent
1923ec1801
commit
360f663119
@ -7,6 +7,7 @@ import dev.mateuszkowalczyk.ffm.image.ThumbnailService;
|
|||||||
import dev.mateuszkowalczyk.ffm.utils.PropertiesLoader;
|
import dev.mateuszkowalczyk.ffm.utils.PropertiesLoader;
|
||||||
import dev.mateuszkowalczyk.ffm.utils.Property;
|
import dev.mateuszkowalczyk.ffm.utils.Property;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.image.PixelWriter;
|
import javafx.scene.image.PixelWriter;
|
||||||
import javafx.scene.image.WritableImage;
|
import javafx.scene.image.WritableImage;
|
||||||
@ -36,8 +37,16 @@ public class DirectoryScanner implements Runnable {
|
|||||||
.filter(Files::isRegularFile)
|
.filter(Files::isRegularFile)
|
||||||
.forEach(path -> {
|
.forEach(path -> {
|
||||||
String filename = path.getFileName().toString();
|
String filename = path.getFileName().toString();
|
||||||
|
ImageView imageView;
|
||||||
|
|
||||||
if(this.isImagePath(filename) && !path.toString().contains(".cache")) {
|
if(this.isImagePath(filename) && !path.toString().contains(".cache")) {
|
||||||
Photo photo = new Photo();
|
Photo photo;
|
||||||
|
|
||||||
|
photo = this.photoDAO.findByPath(path.toString());
|
||||||
|
|
||||||
|
if (photo == null) {
|
||||||
|
photo = new Photo();
|
||||||
|
|
||||||
photo.setPath(path.toString());
|
photo.setPath(path.toString());
|
||||||
photo.setFileName(filename);
|
photo.setFileName(filename);
|
||||||
|
|
||||||
@ -61,9 +70,13 @@ public class DirectoryScanner implements Runnable {
|
|||||||
|
|
||||||
new FaceDetector(photo).run();
|
new FaceDetector(photo).run();
|
||||||
|
|
||||||
ImageView imageView = new ImageView(wr);
|
imageView = new ImageView(wr);
|
||||||
imageViews.add(imageView);
|
imageViews.add(imageView);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Image image = new Image("file:" + photo.getCachedPath());
|
||||||
|
imageView = new ImageView(image);
|
||||||
|
}
|
||||||
Platform.runLater(() -> WorkspaceService.getInstance().getMainPageController().addImage(imageView));
|
Platform.runLater(() -> WorkspaceService.getInstance().getMainPageController().addImage(imageView));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -4,6 +4,9 @@ import dev.mateuszkowalczyk.ffm.data.database.annotation.Column;
|
|||||||
import dev.mateuszkowalczyk.ffm.data.database.annotation.PrimaryKey;
|
import dev.mateuszkowalczyk.ffm.data.database.annotation.PrimaryKey;
|
||||||
import dev.mateuszkowalczyk.ffm.data.database.annotation.Table;
|
import dev.mateuszkowalczyk.ffm.data.database.annotation.Table;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
@Table(name = "photos")
|
@Table(name = "photos")
|
||||||
public class Photo {
|
public class Photo {
|
||||||
|
|
||||||
@ -17,6 +20,17 @@ public class Photo {
|
|||||||
@Column
|
@Column
|
||||||
private String cachedPath;
|
private String cachedPath;
|
||||||
|
|
||||||
|
public Photo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Photo(ResultSet resultSet) throws SQLException {
|
||||||
|
this.id = resultSet.getInt("id");
|
||||||
|
this.path = resultSet.getString("path");
|
||||||
|
this.fileName = resultSet.getString("fileName");
|
||||||
|
this.cachedPath = resultSet.getString("cachedPath");
|
||||||
|
}
|
||||||
|
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,26 @@ public class PhotoDAO implements Dao<Photo> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Photo findByPath(String path) {
|
||||||
|
String sql = "SELECT * FROM photos WHERE path = ?";
|
||||||
|
Photo photo = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
PreparedStatement preparedStatement = this.databaseService.getConnection().prepareStatement(sql);
|
||||||
|
preparedStatement.setString(1, path);
|
||||||
|
ResultSet resultSet = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
while (resultSet.next()) {
|
||||||
|
photo = new Photo(resultSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return photo;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Photo photo) {
|
public void update(Photo photo) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user