1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Merge pull request #165 from lexas2509/recursive

Folder preview image will be taken from all child directories not only direct childs
This commit is contained in:
Patrik J. Braun 2021-01-24 18:42:20 +01:00 committed by GitHub
commit db1fea37fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View File

@ -291,18 +291,27 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
}
if (dir.directories) {
for (let i = 0; i < dir.directories.length; i++) {
const dirName = GalleryManager.getAbsoluteDirName(dir.directories[i]);
dir.directories[i].media = await connection
.getRepository(MediaEntity)
.createQueryBuilder('media')
.innerJoinAndSelect('media.directory', 'directory')
.where('media.directory = :dir', {
dir: dir.directories[i].id
})
.orderBy('media.metadata.creationDate', 'ASC')
.orWhere("directory.path like :parentPath||'%'", {
parentPath: dirName
})
.orderBy('media.metadata.creationDate', 'DESC')
.limit(Config.Server.Indexing.folderPreviewSize)
.getMany();
dir.directories[i].isPartial = true;
for (let j = 0; j < dir.directories[i].media.length; j++) {
const dirs = dir.directories[i]
for (let j = 0; j < dirs.media.length; j++) {
const mediaDirName = GalleryManager.getAbsoluteDirName(dirs.media[j].directory);
const name = mediaDirName.substring(dirName.length);
dir.directories[i].media[j].name = name + dir.directories[i].media[j].name
dir.directories[i].media[j].directory = dir.directories[i];
dir.directories[i].media[j].readyThumbnails = [];
dir.directories[i].media[j].readyIcon = false;
@ -311,4 +320,9 @@ export class GalleryManager implements IGalleryManager, ISQLGalleryManager {
}
}
public static getAbsoluteDirName(dir: DirectoryEntity) {
const path = dir.path;
const currentRoot = (path === "./" ? "" : path) ;
return currentRoot + dir.name + "/";
}
}

View File

@ -29,7 +29,7 @@ export class ConfigDiagnostics {
if (databaseConfig.type !== ServerConfig.DatabaseType.memory) {
await SQLConnection.tryConnection(databaseConfig);
}
if (databaseConfig.type !== ServerConfig.DatabaseType.sqlite) {
if (databaseConfig.type === ServerConfig.DatabaseType.sqlite) {
try {
await this.checkReadWritePermission(SQLConnection.getSQLiteDB(databaseConfig));
} catch (e) {