1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-11-24 08:42:24 +02:00

fixing gallery indexing path errors

This commit is contained in:
Braun Patrik 2016-12-28 14:26:19 +01:00
parent d993a3275b
commit 306613260e
4 changed files with 26 additions and 22 deletions

View File

@ -1,8 +1,7 @@
language: node_js
node_js:
- '7'
- '6'
- '4'
- '0.12'
deploy:
provider: heroku
api_key:

View File

@ -10,6 +10,10 @@ class ProjectPathClass {
return path.resolve(pathStr) === path.normalize(pathStr);
}
normalizeRelative(pathStr: string) {
return path.join(pathStr, path.sep);
}
constructor() {
this.Root = path.join(__dirname, "/../");
this.ImageFolder = this.isAbsolutePath(Config.Server.imagesFolder) ? Config.Server.imagesFolder : path.join(this.Root, Config.Server.imagesFolder);

View File

@ -18,10 +18,9 @@ import {ProjectPath} from "../ProjectPath";
export class DiskManager {
public static scanDirectory(relativeDirectoryName: string, cb: (error: any, result: DirectoryDTO) => void) {
console.log("DiskManager: scanDirectory");
let directoryName = path.normalize(path.basename(relativeDirectoryName));
let directoryParent = path.normalize(path.join(path.dirname(relativeDirectoryName), "/"));
let absoluteDirectoryName = path.normalize(path.join(ProjectPath.ImageFolder, relativeDirectoryName));
console.log(directoryName, directoryParent, path.dirname(relativeDirectoryName), path.join(path.dirname(relativeDirectoryName), "/"));
let directoryName = path.basename(relativeDirectoryName);
let directoryParent = path.join(path.dirname(relativeDirectoryName), path.sep);
let absoluteDirectoryName = path.join(ProjectPath.ImageFolder, relativeDirectoryName);
let directory = <DirectoryDTO>{
name: directoryName,
@ -45,7 +44,7 @@ export class DiskManager {
if (fs.statSync(fullFilePath).isDirectory()) {
directory.directories.push(<DirectoryDTO>{
name: file,
path: relativeDirectoryName,
path: path.join(relativeDirectoryName, path.sep),
lastUpdate: Date.now(),
directories: [],
photos: []

View File

@ -6,37 +6,40 @@ import {MySQLConnection} from "./MySQLConnection";
import {DiskManager} from "../DiskManger";
import {PhotoEntity} from "./enitites/PhotoEntity";
import {Utils} from "../../../common/Utils";
import {ProjectPath} from "../../ProjectPath";
export class GalleryManager implements IGalleryManager {
public listDirectory(relativeDirectoryName, cb: (error: any, result: DirectoryDTO) => void) {
let directoryName = path.normalize(path.basename(relativeDirectoryName));
let directoryParent = path.normalize(path.join(path.dirname(relativeDirectoryName), "/"));
relativeDirectoryName = path.normalize(path.join("." + path.sep, relativeDirectoryName));
let directoryName = path.basename(relativeDirectoryName);
let directoryParent = path.join(path.dirname(relativeDirectoryName), path.sep);
console.log("GalleryManager:listDirectory");
console.log(directoryName, directoryParent, path.dirname(relativeDirectoryName), path.join(path.dirname(relativeDirectoryName), "/"));
console.log(directoryName, directoryParent, path.dirname(relativeDirectoryName), ProjectPath.normalizeRelative(path.dirname(relativeDirectoryName)));
MySQLConnection.getConnection().then(async connection => {
let dir = await connection
.getRepository(DirectoryEntity)
.createQueryBuilder("directory_entity")
.where("directory_entity.name = :name AND directory_entity.path = :path", {
.createQueryBuilder("directory")
.where("directory.name = :name AND directory.path = :path", {
name: directoryName,
path: directoryParent
})
.innerJoinAndSelect("directory_entity.directories", "directories")
.innerJoinAndSelect("directory_entity.photos", "photos")
.leftJoinAndSelect("directory.directories", "directories")
.leftJoinAndSelect("directory.photos", "photos")
.getOne();
console.log(dir);
if (dir) {
for (let i = 0; i < dir.photos.length; i++) {
dir.photos[i].directory = dir;
dir.photos[i].metadata.keywords = <any>JSON.parse(<any>dir.photos[i].metadata.keywords);
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.size = <any>JSON.parse(<any>dir.photos[i].metadata.size);
if (dir.photos) {
for (let i = 0; i < dir.photos.length; i++) {
dir.photos[i].directory = dir;
dir.photos[i].metadata.keywords = <any>JSON.parse(<any>dir.photos[i].metadata.keywords);
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.size = <any>JSON.parse(<any>dir.photos[i].metadata.size);
}
}
return cb(null, dir);
}
@ -78,7 +81,6 @@ export class GalleryManager implements IGalleryManager {
await photosRepository.persist(photo);
}
return cb(null, parentDir);