mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-01-06 03:54:12 +02:00
improving indexing algorithm
This commit is contained in:
parent
039c79ced2
commit
42bac658b2
@ -38,6 +38,7 @@ export class GalleryManager implements IGalleryManager {
|
|||||||
dir.photos[i].metadata.cameraData = <any>JSON.parse(<any>dir.photos[i].metadata.cameraData);
|
dir.photos[i].metadata.cameraData = <any>JSON.parse(<any>dir.photos[i].metadata.cameraData);
|
||||||
dir.photos[i].metadata.positionData = <any>JSON.parse(<any>dir.photos[i].metadata.positionData);
|
dir.photos[i].metadata.positionData = <any>JSON.parse(<any>dir.photos[i].metadata.positionData);
|
||||||
dir.photos[i].metadata.size = <any>JSON.parse(<any>dir.photos[i].metadata.size);
|
dir.photos[i].metadata.size = <any>JSON.parse(<any>dir.photos[i].metadata.size);
|
||||||
|
dir.photos[i].readyThumbnails = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ export class GalleryManager implements IGalleryManager {
|
|||||||
MySQLConnection.getConnection().then(async connection => {
|
MySQLConnection.getConnection().then(async connection => {
|
||||||
|
|
||||||
//returning with the result
|
//returning with the result
|
||||||
|
scannedDirectory.photos.forEach(p => p.readyThumbnails = []);
|
||||||
cb(null, scannedDirectory);
|
cb(null, scannedDirectory);
|
||||||
|
|
||||||
//saving to db
|
//saving to db
|
||||||
@ -94,16 +96,20 @@ export class GalleryManager implements IGalleryManager {
|
|||||||
|
|
||||||
for (let i = 0; i < scannedDirectory.directories.length; i++) {
|
for (let i = 0; i < scannedDirectory.directories.length; i++) {
|
||||||
//TODO: simplify algorithm
|
//TODO: simplify algorithm
|
||||||
if ((await directoryRepository.createQueryBuilder("directory")
|
let dir = await directoryRepository.createQueryBuilder("directory")
|
||||||
.where("directory.name = :name AND directory.path = :path", {
|
.where("directory.name = :name AND directory.path = :path", {
|
||||||
name: scannedDirectory.directories[i].name,
|
name: scannedDirectory.directories[i].name,
|
||||||
path: scannedDirectory.directories[i].path
|
path: scannedDirectory.directories[i].path
|
||||||
}).getCount()) > 0) {
|
}).getOne();
|
||||||
continue;
|
|
||||||
|
if (dir) {
|
||||||
|
dir.parent = parentDir;
|
||||||
|
await directoryRepository.persist(dir);
|
||||||
|
} else {
|
||||||
|
scannedDirectory.directories[i].parent = parentDir;
|
||||||
|
(<DirectoryEntity>scannedDirectory.directories[i]).scanned = false;
|
||||||
|
await directoryRepository.persist(<DirectoryEntity>scannedDirectory.directories[i]);
|
||||||
}
|
}
|
||||||
scannedDirectory.directories[i].parent = parentDir;
|
|
||||||
(<DirectoryEntity>scannedDirectory.directories[i]).scanned = false;
|
|
||||||
await directoryRepository.persist(<Array<DirectoryEntity>>scannedDirectory.directories);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user