1
0
Fork 1
mirror of https://gitlab.com/mangadex-pub/mangadex_at_home.git synced 2024-01-19 02:48:37 +00:00

Cleanup some intermediate leftovers

This commit is contained in:
carbotaniuman 2021-08-22 15:16:01 -05:00
parent e396c1025f
commit 98bbcc1734
4 changed files with 104 additions and 130 deletions

View file

@ -98,13 +98,6 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
}
spotless {
java {
targetExclude("build/generated/**/*")
eclipse()
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
kotlin {
ktlint("0.40.0").userData(["disabled_rules": "no-wildcard-imports"])
licenseHeaderFile "license_header"
@ -120,7 +113,6 @@ tasks.register("generateVersion", Copy) {
into "$buildDir/generated/java"
expand templateContext
}
//tasks.named(":kaptKotlin").dependsOn generateVersion
compileJava.dependsOn generateVersion
sourceSets.main.java.srcDir generateVersion

View file

@ -1,15 +1 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "com.squareup.sqldelight") {
useModule("com.squareup.sqldelight:gradle-plugin:${requested.version}")
}
}
}
}
rootProject.name = 'mangadex_at_home'

View file

@ -1,118 +1,114 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package mdnet.cache;
Mangadex@Home
Copyright (c) 2020, MangaDex Network
This file is part of MangaDex@Home.
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.ProxyInputStream;
MangaDex@Home is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.ExecutorService;
MangaDex@Home is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
import static org.apache.commons.io.IOUtils.EOF;
You should have received a copy of the GNU General Public License
along with this MangaDex@Home. If not, see <http://www.gnu.org/licenses/>.
*/
package mdnet.cache
public class CachingInputStream extends ProxyInputStream {
private final OutputStream cache;
private final ExecutorService executor;
private final Runnable onClose;
private boolean eofReached = false;
import org.apache.commons.io.IOUtils
import org.apache.commons.io.input.ProxyInputStream
import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
import java.lang.Runnable
import java.util.concurrent.ExecutorService
import kotlin.Throws
public CachingInputStream(InputStream response, ExecutorService executor, OutputStream cache, Runnable onClose) {
super(response);
this.executor = executor;
this.cache = cache;
this.onClose = onClose;
}
class CachingInputStream(
response: InputStream?,
private val executor: ExecutorService,
private val cache: OutputStream,
private val onClose: Runnable
) : ProxyInputStream(response) {
private var eofReached = false
@Override
public void close() throws IOException {
if (eofReached) {
try {
in.close();
} catch (IOException ignored) {
}
try {
cache.close();
} catch (IOException ignored) {
}
onClose.run();
} else {
executor.submit(() -> {
try {
IOUtils.copy(in, cache);
} catch (IOException ignored) {
} finally {
try {
in.close();
} catch (IOException ignored) {
}
try {
cache.close();
} catch (IOException ignored) {
}
onClose.run();
}
});
}
}
@Throws(IOException::class)
override fun close() {
if (eofReached) {
try {
`in`.close()
} catch (ignored: IOException) {
}
try {
cache.close()
} catch (ignored: IOException) {
}
onClose.run()
} else {
executor.submit {
try {
IOUtils.copy(`in`, cache)
} catch (ignored: IOException) {
} finally {
try {
`in`.close()
} catch (ignored: IOException) {
}
try {
cache.close()
} catch (ignored: IOException) {
}
onClose.run()
}
}
}
}
@Override
public int read() throws IOException {
final int ch = super.read();
if (ch != EOF) {
try {
cache.write(ch);
} catch (IOException ignored) {
// don't let write failures affect the image loading
}
} else {
eofReached = true;
}
return ch;
}
@Throws(IOException::class)
override fun read(): Int {
val ch = super.read()
if (ch != IOUtils.EOF) {
try {
cache.write(ch)
} catch (ignored: IOException) {
// don't let write failures affect the image loading
}
} else {
eofReached = true
}
return ch
}
@Override
public int read(final byte[] bts, final int st, final int end) throws IOException {
final int n = super.read(bts, st, end);
if (n != EOF) {
try {
cache.write(bts, st, n);
} catch (IOException ignored) {
// don't let write failures affect the image loading
}
} else {
eofReached = true;
}
return n;
}
@Throws(IOException::class)
override fun read(bts: ByteArray, st: Int, end: Int): Int {
val n = super.read(bts, st, end)
if (n != IOUtils.EOF) {
try {
cache.write(bts, st, n)
} catch (ignored: IOException) {
// don't let write failures affect the image loading
}
} else {
eofReached = true
}
return n
}
@Override
public int read(final byte[] bts) throws IOException {
final int n = super.read(bts);
if (n != EOF) {
try {
cache.write(bts, 0, n);
} catch (IOException ignored) {
// don't let write failures affect the image loading
}
} else {
eofReached = true;
}
return n;
}
@Throws(IOException::class)
override fun read(bts: ByteArray): Int {
val n = super.read(bts)
if (n != IOUtils.EOF) {
try {
cache.write(bts, 0, n)
} catch (ignored: IOException) {
// don't let write failures affect the image loading
}
} else {
eofReached = true
}
return n
}
}

View file

@ -86,7 +86,7 @@ fun getServer(
val circuited = ResilienceFilters.CircuitBreak(
circuitBreaker,
isError = { r: Response -> !r.status.successful }
isError = { r: Response -> r.status.serverError }
)
val upstream = ClientFilters.MicrometerMetrics.RequestTimer(registry)