Small fixes

This commit is contained in:
crschnick 2024-06-24 02:20:21 +00:00
parent 36379174fa
commit 2d636de52a
5 changed files with 13 additions and 18 deletions

View file

@ -48,8 +48,10 @@ public class BlobManager {
INSTANCE = null;
}
public Path newBlobFile() {
return TEMP.resolve(UUID.randomUUID().toString());
public Path newBlobFile() throws IOException {
var file = TEMP.resolve(UUID.randomUUID().toString());
Files.createDirectories(file.getParent());
return file;
}
public void store(UUID uuid, byte[] blob) {

View file

@ -30,9 +30,8 @@ public class FsReadExchangeImpl extends FsReadExchange {
if (size > 100_000_000) {
var file = BlobManager.get().newBlobFile();
try (var in = fs.openInput(msg.getPath().toString())) {
try (var fileOut =
Files.newOutputStream(file.resolve(msg.getPath().getFileName()));
var fixedIn = new FixedSizeInputStream(new BufferedInputStream(in), size)) {
var fixedIn = new FixedSizeInputStream(new BufferedInputStream(in), size);
try (var fileOut = Files.newOutputStream(file.resolve(msg.getPath().getFileName()))) {
fixedIn.transferTo(fileOut);
}
in.transferTo(OutputStream.nullOutputStream());
@ -47,9 +46,8 @@ public class FsReadExchangeImpl extends FsReadExchange {
} else {
byte[] bytes;
try (var in = fs.openInput(msg.getPath().toString())) {
try (var fixedIn = new FixedSizeInputStream(new BufferedInputStream(in), size)) {
bytes = fixedIn.readAllBytes();
}
var fixedIn = new FixedSizeInputStream(new BufferedInputStream(in), size);
bytes = fixedIn.readAllBytes();
in.transferTo(OutputStream.nullOutputStream());
}
exchange.sendResponseHeaders(200, bytes.length);

View file

@ -1,19 +1,16 @@
package io.xpipe.app.browser;
import atlantafx.base.theme.Styles;
import io.xpipe.app.comp.store.StoreCategoryWrapper;
import io.xpipe.app.comp.store.StoreViewState;
import io.xpipe.app.core.AppFont;
import io.xpipe.app.fxcomps.SimpleComp;
import io.xpipe.app.fxcomps.impl.FilterComp;
import io.xpipe.app.fxcomps.impl.HorizontalComp;
import io.xpipe.app.util.DataStoreCategoryChoiceComp;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.layout.Region;
import atlantafx.base.theme.Styles;
import lombok.Getter;
import java.util.List;
@ -31,11 +28,9 @@ public final class BrowserBookmarkHeaderComp extends SimpleComp {
StoreViewState.get().getAllConnectionsCategory(),
StoreViewState.get().getActiveCategory(),
this.category)
.styleClass(Styles.LEFT_PILL)
.apply(struc -> AppFont.medium(struc.get()));
.styleClass(Styles.LEFT_PILL);
var filter = new FilterComp(this.filter)
.styleClass(Styles.RIGHT_PILL)
.apply(struc -> AppFont.medium(struc.get()))
.hgrow();
var top = new HorizontalComp(List.of(category, filter))

View file

@ -111,9 +111,8 @@ public class FileBridge {
try (var in = Files.newInputStream(e.file)) {
var actualSize = (long) in.available();
var started = Instant.now();
try (var fixedIn = new FixedSizeInputStream(new BufferedInputStream(in), actualSize)) {
e.writer.accept(fixedIn, actualSize);
}
var fixedIn = new FixedSizeInputStream(new BufferedInputStream(in), actualSize);
e.writer.accept(fixedIn, actualSize);
in.transferTo(OutputStream.nullOutputStream());
var taken = Duration.between(started, Instant.now());
event("Wrote " + HumanReadableFormat.byteCount(actualSize) + " in " + taken.toMillis() + "ms");

View file

@ -61,6 +61,7 @@
.browser .browser-content.overview {
-fx-spacing: 1.5em;
-fx-padding: 1.5em;
-fx-background-color: -color-bg-default;
}
.selected-file-list {