1
mirror of https://github.com/revanced/revanced-patcher synced 2025-09-06 16:38:50 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
semantic-release-bot
783b2de9db chore(release): 2.5.1 [skip ci]
## [2.5.1](https://github.com/revanced/revanced-patcher/compare/v2.5.0...v2.5.1) (2022-07-17)

### Bug Fixes

* close stream when closing `DomFileEditor` ([77604d4](77604d4078))
2022-07-17 23:30:04 +00:00
oSumAtrIX
77604d4078 fix: close stream when closing DomFileEditor 2022-07-18 01:28:16 +02:00
oSumAtrIX
21b5404180 docs: change size of headings [skip ci] 2022-07-12 01:12:45 +02:00
5 changed files with 30 additions and 15 deletions

View File

@@ -7,18 +7,18 @@ assignees: oSumAtrIX, Sculas
---
# 🐞 Issue
## 🐞 Issue
<!-- Describe your issue in detail here -->
# ⚙ Reproduce
## ⚙ Reproduce
<!-- Include your environment and steps to reproduce the issue as detailed as possible -->
# 🛠 Solution
## 🛠 Solution
<!-- If applicable, add a possible solution -->
# ⚠ Additional context
## ⚠ Additional context
<!-- Add any other context about the problem here -->

View File

@@ -3,21 +3,22 @@ name: Feature request
about: Suggest a change for the patcher. Do not submit suggestions for patches here.
title: 'feat: some feature'
labels: feature-request
assignees: ''
---
# 🐞 Issue
## 🐞 Issue
<!-- Explain here, what the current problem is and why it lead you to request a feature change -->
<!-- Explain here, what the current problem is and why it leads you to request a feature change -->
# ❗ Solution
## ❗ Solution
<!-- Explain how your current issue can be solved -->
# ❓ Motivation
## ❓ Motivation
<!-- Explain why your feature should be considered -->
# ⚠ Additional context
## ⚠ Additional context
<!-- Add any other context or screenshots about the feature request here -->

View File

@@ -1,3 +1,10 @@
## [2.5.1](https://github.com/revanced/revanced-patcher/compare/v2.5.0...v2.5.1) (2022-07-17)
### Bug Fixes
* close stream when closing `DomFileEditor` ([77604d4](https://github.com/revanced/revanced-patcher/commit/77604d40785847b775155c0e75b663a3c7336aa3))
# [2.5.0](https://github.com/revanced/revanced-patcher/compare/v2.4.0...v2.5.0) (2022-07-11)

View File

@@ -1,2 +1,2 @@
kotlin.code.style = official
version = 2.5.0
version = 2.5.1

View File

@@ -26,17 +26,24 @@ class ResourceData(private val resourceCacheDirectory: File) : Data, Iterable<Fi
}
}
class DomFileEditor internal constructor(inputStream: InputStream, private val outputStream: Lazy<OutputStream>) : Closeable {
class DomFileEditor internal constructor(
private val inputStream: InputStream,
private val outputStream: Lazy<OutputStream>,
) : Closeable {
val file: Document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream)
.also(Document::normalize)
// lazily open an output stream
// this is required because when constructing a DomFileEditor the output stream is created along with the input stream, which is not allowed
// the workaround is to lazily create the output stream. This way it would be used after the input stream is closed, which happens in the constructor
constructor(file: File) : this(file.inputStream(), lazy { file.outputStream() })
val file: Document =
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream).also(Document::normalize)
override fun close() {
val result = StreamResult(outputStream.value)
TransformerFactory.newInstance().newTransformer().transform(DOMSource(file), result)
override fun close() =
TransformerFactory.newInstance().newTransformer().transform(DOMSource(file), StreamResult(outputStream.value))
inputStream.close()
outputStream.value.close()
}
}