File name fix
This commit is contained in:
parent
46e3fb966c
commit
209a6db5fc
@ -56,6 +56,7 @@ internal suspend fun SpaceClient.extractFile(
|
||||
}
|
||||
|
||||
private val imageRegex = """!\[(?<alt>.*)]\(/d/(?<id>.*)\?f=0( "(?<name>.*)")?\)""".toRegex()
|
||||
private val fileNameRegex = "\\W+".toRegex()
|
||||
|
||||
/**
|
||||
* Download single Space document
|
||||
@ -90,13 +91,14 @@ internal suspend fun SpaceClient.downloadDocument(
|
||||
val id = it.groups["id"]?.value ?: error("Unexpected reference format: ${it.value}")
|
||||
val alt = it.groups["alt"]?.value?.ifBlank { null }
|
||||
val name = it.groups["name"]?.value?.ifBlank { null }
|
||||
val imageName = name?.let { "$id-$name" } ?: alt?.let { "$id-$alt" } ?: id
|
||||
val imageName = (name?.let { "$id-$name" } ?: alt?.let { "$id-$alt" } ?: id)
|
||||
.replace(fileNameRegex, "_")
|
||||
val imageFile = imageDirectory.resolve(imageName)
|
||||
logger.info("Downloading image $id as $imageFile")
|
||||
launch(Dispatchers.IO) {
|
||||
extractAttachment(imageFile, id)
|
||||
}
|
||||
"![${alt?:""}](images/$imageName)"
|
||||
"![${alt ?: ""}](images/$imageName)"
|
||||
}
|
||||
markdownFilePath.writeText(newText, Charsets.UTF_8)
|
||||
}
|
||||
@ -131,6 +133,7 @@ internal suspend fun SpaceClient.downloadDocumentFolder(
|
||||
documents.data.forEach {
|
||||
val document = projects.documents.getDocument(projectId, it.id) {
|
||||
body()
|
||||
bodyType()
|
||||
title()
|
||||
id()
|
||||
}
|
||||
@ -146,6 +149,7 @@ internal suspend fun SpaceClient.downloadDocumentFolder(
|
||||
)
|
||||
) {
|
||||
body()
|
||||
bodyType()
|
||||
title()
|
||||
id()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user