mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
Merge pull request #844 from mblythe86/ext_excludeDir
Add excludeDir to extension interface
This commit is contained in:
commit
eb36707062
@ -55,6 +55,7 @@ export class ExtensionManager implements IObjectManager {
|
|||||||
invalidateDirectoryCovers: new ExtensionEvent(),
|
invalidateDirectoryCovers: new ExtensionEvent(),
|
||||||
},
|
},
|
||||||
DiskManager: {
|
DiskManager: {
|
||||||
|
excludeDir: new ExtensionEvent(),
|
||||||
scanDirectory: new ExtensionEvent()
|
scanDirectory: new ExtensionEvent()
|
||||||
},
|
},
|
||||||
ImageRenderer: {
|
ImageRenderer: {
|
||||||
|
@ -73,6 +73,11 @@ export interface IExtensionEvents {
|
|||||||
* photos, videos and metafiles
|
* photos, videos and metafiles
|
||||||
*/
|
*/
|
||||||
DiskManager: {
|
DiskManager: {
|
||||||
|
excludeDir: IExtensionEvent<[{
|
||||||
|
name: string,
|
||||||
|
parentDirRelativeName: string,
|
||||||
|
parentDirAbsoluteName: string
|
||||||
|
}], boolean>,
|
||||||
scanDirectory: IExtensionEvent<[
|
scanDirectory: IExtensionEvent<[
|
||||||
string,
|
string,
|
||||||
DirectoryScanSettings], ParentDirectoryDTO>
|
DirectoryScanSettings], ParentDirectoryDTO>
|
||||||
|
@ -49,19 +49,20 @@ export class DiskManager {
|
|||||||
return path.basename(dirPath);
|
return path.basename(dirPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async excludeDir(
|
@ExtensionDecorator(e => e.gallery.DiskManager.excludeDir)
|
||||||
|
public static async excludeDir(dir: {
|
||||||
name: string,
|
name: string,
|
||||||
relativeDirectoryName: string,
|
parentDirRelativeName: string,
|
||||||
absoluteDirectoryName: string
|
parentDirAbsoluteName: string
|
||||||
): Promise<boolean> {
|
}): Promise<boolean> {
|
||||||
if (
|
if (
|
||||||
Config.Indexing.excludeFolderList.length === 0 &&
|
Config.Indexing.excludeFolderList.length === 0 &&
|
||||||
Config.Indexing.excludeFileList.length === 0
|
Config.Indexing.excludeFileList.length === 0
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const absoluteName = path.normalize(path.join(absoluteDirectoryName, name));
|
const absoluteName = path.normalize(path.join(dir.parentDirAbsoluteName, dir.name));
|
||||||
const relativeName = path.normalize(path.join(relativeDirectoryName, name));
|
const relativeName = path.normalize(path.join(dir.parentDirRelativeName, dir.name));
|
||||||
|
|
||||||
for (const exclude of Config.Indexing.excludeFolderList) {
|
for (const exclude of Config.Indexing.excludeFolderList) {
|
||||||
if (exclude.startsWith('/')) {
|
if (exclude.startsWith('/')) {
|
||||||
@ -73,7 +74,7 @@ export class DiskManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (exclude === name) {
|
if (exclude === dir.name) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,11 +156,11 @@ export class DiskManager {
|
|||||||
if (
|
if (
|
||||||
settings.noDirectory === true ||
|
settings.noDirectory === true ||
|
||||||
settings.coverOnly === true ||
|
settings.coverOnly === true ||
|
||||||
(await DiskManager.excludeDir(
|
(await DiskManager.excludeDir({
|
||||||
file,
|
name: file,
|
||||||
relativeDirectoryName,
|
parentDirRelativeName: relativeDirectoryName,
|
||||||
absoluteDirectoryName
|
parentDirAbsoluteName: absoluteDirectoryName
|
||||||
))
|
}))
|
||||||
) {
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user