File-based providers no longer throw exception if dir does not exist or is not a dir.

This commit is contained in:
JesseBrault0709 2023-01-13 09:08:58 -06:00
parent c312b0cf8f
commit 0b95f4662d
4 changed files with 60 additions and 54 deletions

View File

@ -24,7 +24,7 @@ class PartFilePartsProvider implements PartsProvider, WithWatchableDir {
}
private PartType getPartType(File file) {
partTypes.find {
this.partTypes.find {
it.ids.contains(new FileNameHandler(file).getExtension())
}
}
@ -32,11 +32,11 @@ class PartFilePartsProvider implements PartsProvider, WithWatchableDir {
@Override
Collection<Part> provide() {
if (!partsDir.isDirectory()) {
throw new IllegalArgumentException('partsDir must be a directory')
}
logger.warn('partsDir {} does not exist or is not a directory; skipping and providing no Parts', this.partsDir)
[]
} else {
def parts = []
partsDir.eachFileRecurse(FileType.FILES) {
this.partsDir.eachFileRecurse(FileType.FILES) {
def type = this.getPartType(it)
if (type != null) {
def relativePath = this.partsDir.relativePath(it)
@ -48,6 +48,7 @@ class PartFilePartsProvider implements PartsProvider, WithWatchableDir {
}
parts
}
}
@Override
Collection<PartType> getPartTypes() {

View File

@ -33,9 +33,9 @@ class SpecialPageFileSpecialPagesProvider implements SpecialPagesProvider, WithW
@Override
Collection<SpecialPage> provide() {
if (!this.specialPagesDir.isDirectory()) {
throw new IllegalArgumentException('specialPagesDir must be a directory')
}
logger.warn('specialPagesDir {} does not exist or is not a directory; skipping and providing no SpecialPages', this.specialPagesDir)
[]
} else {
def specialPages = []
this.specialPagesDir.eachFileRecurse(FileType.FILES) {
def type = this.getSpecialPageType(it)
@ -50,6 +50,7 @@ class SpecialPageFileSpecialPagesProvider implements SpecialPagesProvider, WithW
}
specialPages
}
}
@Override
Collection<SpecialPageType> getSpecialPageTypes() {

View File

@ -32,8 +32,9 @@ class TemplateFileTemplatesProvider implements TemplatesProvider, WithWatchableD
@Override
Collection<Template> provide() {
if (!this.templatesDir.isDirectory()) {
throw new IllegalArgumentException('templatesDir must be a directory')
}
logger.warn('templatesDir {} does not exist or is not a directory; skipping and providing no Templates', this.templatesDir)
[]
} else {
def templates = []
this.templatesDir.eachFileRecurse(FileType.FILES) {
def type = this.getType(it)
@ -47,6 +48,7 @@ class TemplateFileTemplatesProvider implements TemplatesProvider, WithWatchableD
}
templates
}
}
@Override
Collection<TemplateType> getTemplateTypes() {

View File

@ -21,9 +21,6 @@ class TextFileTextsProvider implements TextsProvider, WithWatchableDir {
TextFileTextsProvider(Collection<TextType> textTypes, File textsDir) {
this.textTypes = textTypes
this.textsDir = textsDir
if (!this.textsDir.isDirectory()) {
throw new IllegalArgumentException('textsDir must be a directory, given: ' + this.textsDir)
}
this.watchableDir = this.textsDir
}
@ -35,6 +32,10 @@ class TextFileTextsProvider implements TextsProvider, WithWatchableDir {
@Override
Collection<Text> provide() {
if (!this.textsDir.isDirectory()) {
logger.warn('textsDir {} does not exist or is not a directory; skipping and providing no Texts', this.textsDir)
[]
} else {
def textFiles = []
this.textsDir.eachFileRecurse(FileType.FILES) {
def type = this.getTextType(it)
@ -49,6 +50,7 @@ class TextFileTextsProvider implements TextsProvider, WithWatchableDir {
}
textFiles
}
}
@Override
Collection<TextType> getTextTypes() {