Ability to exclude directories, and config to choose them.
This commit is contained in:
parent
91d69dcf3d
commit
719a2e01d8
@ -57,6 +57,50 @@ export class DiskMangerWorker {
|
|||||||
return path.basename(name);
|
return path.basename(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static excludeDir(name: string,relativeDirectoryName: string, absoluteDirectoryName: string) {
|
||||||
|
const absoluteName=path.normalize(path.join(absoluteDirectoryName,name));
|
||||||
|
const relativeName=path.normalize(path.join(relativeDirectoryName,name));
|
||||||
|
|
||||||
|
|
||||||
|
console.log("----- Starting exlude dir -----");
|
||||||
|
console.log("name %s",name);
|
||||||
|
console.log("absoluteDirectoryName %s",absoluteDirectoryName);
|
||||||
|
console.log("absoluteName %s",absoluteName);
|
||||||
|
console.log("relativeDirectoryName %s",relativeDirectoryName);
|
||||||
|
console.log("relativeName %s",relativeName);
|
||||||
|
console.log("Config.Server.indexing.excludeFolderList %s",Config.Server.indexing.excludeFolderList);
|
||||||
|
|
||||||
|
for (let j = 0; j < Config.Server.indexing.excludeFolderList.length; j++) {
|
||||||
|
const exclude=Config.Server.indexing.excludeFolderList[j];
|
||||||
|
console.log("trying dir %s",exclude);
|
||||||
|
|
||||||
|
if (exclude.startsWith('/')) {
|
||||||
|
if (exclude==absoluteName) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (exclude.includes('/')) {
|
||||||
|
if (path.normalize(exclude)==relativeName) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (exclude==name) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let j = 0; j < Config.Server.indexing.excludeFileList.length; j++) {
|
||||||
|
const exclude=Config.Server.indexing.excludeFileList[j];
|
||||||
|
console.log("trying file %s",exclude);
|
||||||
|
|
||||||
|
if (fs.existsSync(path.join(absoluteName,exclude))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static scanDirectory(relativeDirectoryName: string, maxPhotos: number = null, photosOnly: boolean = false): Promise<DirectoryDTO> {
|
public static scanDirectory(relativeDirectoryName: string, maxPhotos: number = null, photosOnly: boolean = false): Promise<DirectoryDTO> {
|
||||||
return new Promise<DirectoryDTO>((resolve, reject) => {
|
return new Promise<DirectoryDTO>((resolve, reject) => {
|
||||||
relativeDirectoryName = this.normalizeDirPath(relativeDirectoryName);
|
relativeDirectoryName = this.normalizeDirPath(relativeDirectoryName);
|
||||||
@ -90,6 +134,9 @@ export class DiskMangerWorker {
|
|||||||
if (photosOnly === true) {
|
if (photosOnly === true) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (DiskMangerWorker.excludeDir(file,relativeDirectoryName,absoluteDirectoryName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const d = await DiskMangerWorker.scanDirectory(path.join(relativeDirectoryName, file),
|
const d = await DiskMangerWorker.scanDirectory(path.join(relativeDirectoryName, file),
|
||||||
Config.Server.indexing.folderPreviewSize, true
|
Config.Server.indexing.folderPreviewSize, true
|
||||||
);
|
);
|
||||||
|
|||||||
@ -54,6 +54,8 @@ export interface IndexingConfig {
|
|||||||
folderPreviewSize: number;
|
folderPreviewSize: number;
|
||||||
cachedFolderTimeout: number; // Do not rescans the folder if seems ok
|
cachedFolderTimeout: number; // Do not rescans the folder if seems ok
|
||||||
reIndexingSensitivity: ReIndexingSensitivity;
|
reIndexingSensitivity: ReIndexingSensitivity;
|
||||||
|
excludeFolderList: string[]
|
||||||
|
excludeFileList: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ThreadingConfig {
|
export interface ThreadingConfig {
|
||||||
|
|||||||
@ -57,7 +57,9 @@ export class PrivateConfigClass extends PublicConfigClass implements IPrivateCon
|
|||||||
indexing: {
|
indexing: {
|
||||||
folderPreviewSize: 2,
|
folderPreviewSize: 2,
|
||||||
cachedFolderTimeout: 1000 * 60 * 60,
|
cachedFolderTimeout: 1000 * 60 * 60,
|
||||||
reIndexingSensitivity: ReIndexingSensitivity.low
|
reIndexingSensitivity: ReIndexingSensitivity.low,
|
||||||
|
excludeFolderList: [],
|
||||||
|
excludeFileList: []
|
||||||
},
|
},
|
||||||
duplicates: {
|
duplicates: {
|
||||||
listingLimit: 1000
|
listingLimit: 1000
|
||||||
|
|||||||
@ -49,6 +49,36 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-md-2 control-label" for="excludeFolderList" i18n>Exclude Folder List</label>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<input type="text" class="form-control" placeholder=""
|
||||||
|
id="excludeFolderList"
|
||||||
|
[(ngModel)]="excludeFolderList"
|
||||||
|
name="excludeFolderList" required>
|
||||||
|
<small class="form-text text-muted">
|
||||||
|
<ng-container i18n>Folders to exclude from indexing</ng-container><br/>
|
||||||
|
<ng-container
|
||||||
|
i18n>';' separated strings. If an entry starts with '/' it is treated as an absolute path. If it doesn't start with '/' but contains a '/', the path is relative to the image directory. If it doesn't contain a '/', any folder with this name will be excluded.</ng-container>
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-md-2 control-label" for="excludeFileList" i18n>Exclude File List</label>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<input type="text" class="form-control" placeholder=""
|
||||||
|
id="excludeFileList"
|
||||||
|
[(ngModel)]="excludeFileList"
|
||||||
|
name="excludeFileList" required>
|
||||||
|
<small class="form-text text-muted">
|
||||||
|
<ng-container i18n>FFiles that mark a folder to be excluded from indexing</ng-container><br/>
|
||||||
|
<ng-container
|
||||||
|
i18n>';' separated strings. Any folder that contains a file with this name will be excluded from indexing.</ng-container>
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<button class="btn btn-success float-right"
|
<button class="btn btn-success float-right"
|
||||||
[disabled]="!settingsForm.form.valid || !changed || inProgress"
|
[disabled]="!settingsForm.form.valid || !changed || inProgress"
|
||||||
|
|||||||
@ -81,6 +81,22 @@ export class IndexingSettingsComponent extends SettingsComponent<IndexingConfig,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
get excludeFolderList(): string {
|
||||||
|
return this.settings.excludeFolderList.join(';');
|
||||||
|
}
|
||||||
|
|
||||||
|
set excludeFolderList(value: string) {
|
||||||
|
this.settings.excludeFolderList = value.split(';');
|
||||||
|
}
|
||||||
|
|
||||||
|
get excludeFileList(): string {
|
||||||
|
return this.settings.excludeFileList.join(';');
|
||||||
|
}
|
||||||
|
|
||||||
|
set excludeFileList(value: string) {
|
||||||
|
this.settings.excludeFileList = value.split(';');
|
||||||
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
this.types = Utils
|
this.types = Utils
|
||||||
|
|||||||
@ -109,7 +109,9 @@ export class SettingsService {
|
|||||||
indexing: {
|
indexing: {
|
||||||
cachedFolderTimeout: 0,
|
cachedFolderTimeout: 0,
|
||||||
folderPreviewSize: 0,
|
folderPreviewSize: 0,
|
||||||
reIndexingSensitivity: ReIndexingSensitivity.medium
|
reIndexingSensitivity: ReIndexingSensitivity.medium,
|
||||||
|
excludeFolderList: [],
|
||||||
|
excludeFileList: []
|
||||||
},
|
},
|
||||||
photoMetadataSize: 512 * 1024,
|
photoMetadataSize: 512 * 1024,
|
||||||
duplicates: {
|
duplicates: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user