File-based providers no longer throw exception if dir does not exist or is not a dir.
This commit is contained in:
parent
c312b0cf8f
commit
0b95f4662d
@ -24,7 +24,7 @@ class PartFilePartsProvider implements PartsProvider, WithWatchableDir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PartType getPartType(File file) {
|
private PartType getPartType(File file) {
|
||||||
partTypes.find {
|
this.partTypes.find {
|
||||||
it.ids.contains(new FileNameHandler(file).getExtension())
|
it.ids.contains(new FileNameHandler(file).getExtension())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,11 +32,11 @@ class PartFilePartsProvider implements PartsProvider, WithWatchableDir {
|
|||||||
@Override
|
@Override
|
||||||
Collection<Part> provide() {
|
Collection<Part> provide() {
|
||||||
if (!partsDir.isDirectory()) {
|
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 = []
|
def parts = []
|
||||||
partsDir.eachFileRecurse(FileType.FILES) {
|
this.partsDir.eachFileRecurse(FileType.FILES) {
|
||||||
def type = this.getPartType(it)
|
def type = this.getPartType(it)
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
def relativePath = this.partsDir.relativePath(it)
|
def relativePath = this.partsDir.relativePath(it)
|
||||||
@ -48,6 +48,7 @@ class PartFilePartsProvider implements PartsProvider, WithWatchableDir {
|
|||||||
}
|
}
|
||||||
parts
|
parts
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Collection<PartType> getPartTypes() {
|
Collection<PartType> getPartTypes() {
|
||||||
|
@ -33,9 +33,9 @@ class SpecialPageFileSpecialPagesProvider implements SpecialPagesProvider, WithW
|
|||||||
@Override
|
@Override
|
||||||
Collection<SpecialPage> provide() {
|
Collection<SpecialPage> provide() {
|
||||||
if (!this.specialPagesDir.isDirectory()) {
|
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 = []
|
def specialPages = []
|
||||||
this.specialPagesDir.eachFileRecurse(FileType.FILES) {
|
this.specialPagesDir.eachFileRecurse(FileType.FILES) {
|
||||||
def type = this.getSpecialPageType(it)
|
def type = this.getSpecialPageType(it)
|
||||||
@ -50,6 +50,7 @@ class SpecialPageFileSpecialPagesProvider implements SpecialPagesProvider, WithW
|
|||||||
}
|
}
|
||||||
specialPages
|
specialPages
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Collection<SpecialPageType> getSpecialPageTypes() {
|
Collection<SpecialPageType> getSpecialPageTypes() {
|
||||||
|
@ -32,8 +32,9 @@ class TemplateFileTemplatesProvider implements TemplatesProvider, WithWatchableD
|
|||||||
@Override
|
@Override
|
||||||
Collection<Template> provide() {
|
Collection<Template> provide() {
|
||||||
if (!this.templatesDir.isDirectory()) {
|
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 = []
|
def templates = []
|
||||||
this.templatesDir.eachFileRecurse(FileType.FILES) {
|
this.templatesDir.eachFileRecurse(FileType.FILES) {
|
||||||
def type = this.getType(it)
|
def type = this.getType(it)
|
||||||
@ -47,6 +48,7 @@ class TemplateFileTemplatesProvider implements TemplatesProvider, WithWatchableD
|
|||||||
}
|
}
|
||||||
templates
|
templates
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Collection<TemplateType> getTemplateTypes() {
|
Collection<TemplateType> getTemplateTypes() {
|
||||||
|
@ -21,9 +21,6 @@ class TextFileTextsProvider implements TextsProvider, WithWatchableDir {
|
|||||||
TextFileTextsProvider(Collection<TextType> textTypes, File textsDir) {
|
TextFileTextsProvider(Collection<TextType> textTypes, File textsDir) {
|
||||||
this.textTypes = textTypes
|
this.textTypes = textTypes
|
||||||
this.textsDir = textsDir
|
this.textsDir = textsDir
|
||||||
if (!this.textsDir.isDirectory()) {
|
|
||||||
throw new IllegalArgumentException('textsDir must be a directory, given: ' + this.textsDir)
|
|
||||||
}
|
|
||||||
this.watchableDir = this.textsDir
|
this.watchableDir = this.textsDir
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,6 +32,10 @@ class TextFileTextsProvider implements TextsProvider, WithWatchableDir {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
Collection<Text> provide() {
|
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 = []
|
def textFiles = []
|
||||||
this.textsDir.eachFileRecurse(FileType.FILES) {
|
this.textsDir.eachFileRecurse(FileType.FILES) {
|
||||||
def type = this.getTextType(it)
|
def type = this.getTextType(it)
|
||||||
@ -49,6 +50,7 @@ class TextFileTextsProvider implements TextsProvider, WithWatchableDir {
|
|||||||
}
|
}
|
||||||
textFiles
|
textFiles
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Collection<TextType> getTextTypes() {
|
Collection<TextType> getTextTypes() {
|
||||||
|
Loading…
Reference in New Issue
Block a user