mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-16 08:15:48 +00:00
WIP: Some performance improvements (maybe)
This commit is contained in:
@@ -76,11 +76,6 @@
|
|||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>${commons-io.version}</version>
|
<version>${commons-io.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-compress</artifactId>
|
|
||||||
<version>${commons-compress.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Protobuf dependencies -->
|
<!-- Protobuf dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import java.util.zip.Deflater;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@@ -276,37 +278,24 @@ public class FilesystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void downloadFilesAsZip(Path path, OutputStream outputStream) {
|
private void downloadFilesAsZip(Path path, OutputStream outputStream) {
|
||||||
final ParallelScatterZipCreator scatterZipCreator = new ParallelScatterZipCreator();
|
ZipOutputStream zos = new ZipOutputStream(outputStream){{
|
||||||
|
def.setLevel(Deflater.NO_COMPRESSION);
|
||||||
ZipArchiveOutputStream zipArchiveOutputStream;
|
}};
|
||||||
|
|
||||||
zipArchiveOutputStream = new ZipArchiveOutputStream(outputStream);
|
|
||||||
zipArchiveOutputStream.setUseZip64(Zip64Mode.AsNeeded);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Files.walkFileTree(path, new SimpleFileVisitor<>() {
|
Files.walkFileTree(path, new SimpleFileVisitor<>() {
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||||
InputStreamSupplier streamSupplier = () -> {
|
zos.putNextEntry(new ZipEntry(path.relativize(file).toString()));
|
||||||
InputStream is = null;
|
Files.copy(file, zos);
|
||||||
try {
|
zos.closeEntry();
|
||||||
is = Files.newInputStream(file);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return is;
|
|
||||||
};
|
|
||||||
|
|
||||||
ZipArchiveEntry zipArchiveEntry = new ZipArchiveEntry(path.relativize(file).toString());
|
|
||||||
zipArchiveEntry.setMethod(ZipEntry.STORED);
|
|
||||||
scatterZipCreator.addArchiveEntry(zipArchiveEntry, streamSupplier);
|
|
||||||
|
|
||||||
return FileVisitResult.CONTINUE;
|
return FileVisitResult.CONTINUE;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
scatterZipCreator.writeTo(zipArchiveOutputStream);
|
|
||||||
zipArchiveOutputStream.close();
|
zos.close();
|
||||||
} catch (IOException | InterruptedException | ExecutionException e) {
|
} catch (IOException e) {
|
||||||
log.error("Error while zipping files:", e);
|
log.error("Error while zipping files:", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
gameyfin:
|
gameyfin:
|
||||||
#root: C:\Projects\privat\gameyfin-library
|
#root: C:\Projects\privat\gameyfin-library
|
||||||
#root: \\NAS-Simon\Öffentlich\Spiele
|
root: \\NAS-Simon\Öffentlich\Spiele
|
||||||
root: C:\gameyfin-library
|
|
||||||
cache: ${gameyfin.root}\.gameyfin\cache
|
cache: ${gameyfin.root}\.gameyfin\cache
|
||||||
#db: ${gameyfin.root}\.gameyfin\db
|
#db: ${gameyfin.root}\.gameyfin\db
|
||||||
db: ./data
|
db: ./data
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ server:
|
|||||||
error.include-stacktrace: never
|
error.include-stacktrace: never
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
|
mvc:
|
||||||
|
async.request-timeout: -1
|
||||||
jackson.default-property-inclusion: non_null
|
jackson.default-property-inclusion: non_null
|
||||||
datasource.db-name: gameyfin_db
|
datasource.db-name: gameyfin_db
|
||||||
datasource.url: jdbc:h2:file:${gameyfin.db}/${spring.datasource.db-name};AUTO_SERVER=TRUE
|
datasource.url: jdbc:h2:file:${gameyfin.db}/${spring.datasource.db-name};AUTO_SERVER=TRUE
|
||||||
|
|||||||
Reference in New Issue
Block a user