This commit is contained in:
crschnick
2026-06-19 10:55:16 +00:00
parent 8e8a34f2c5
commit a2392ed1df
6 changed files with 18 additions and 8 deletions
@@ -53,6 +53,14 @@ public class BlobManager {
return file;
}
public long getSize(UUID id) throws IOException {
if (memoryBlobs.containsKey(id)) {
return memoryBlobs.get(id).length;
} else {
return Files.size(fileBlobs.get(id));
}
}
public void store(UUID uuid, byte[] blob) {
memoryBlobs.put(uuid, blob);
}
@@ -13,6 +13,7 @@ import lombok.SneakyThrows;
import lombok.Value;
import lombok.extern.jackson.Jacksonized;
import java.nio.file.Files;
import java.util.UUID;
public class FsWriteExchange extends BeaconInterface<FsWriteExchange.Request> {
@@ -28,7 +29,7 @@ public class FsWriteExchange extends BeaconInterface<FsWriteExchange.Request> {
var shell = AppBeaconServer.get().getCache().getShellSession(msg.getStore());
var fs = new ConnectionFileSystem(shell.getControl());
try (var in = BlobManager.get().getBlob(msg.getBlob());
var os = fs.openOutput(msg.getPath(), in.available())) {
var os = fs.openOutput(msg.getPath(), BlobManager.get().getSize(msg.getBlob()))) {
in.transferTo(os);
}
return Response.builder().build();
@@ -31,7 +31,7 @@ public class AppWindowsLock {
User32.INSTANCE.GetWindowLongPtr(hwnd, GWLP_WNDPROC).toPointer();
User32Ex.INSTANCE.SetWindowLongPtr(hwnd, GWLP_WNDPROC, PROC);
} catch (Throwable t) {
ErrorEventFactory.fromThrowable(t).omit().handle();
ErrorEventFactory.fromThrowable(t).omit().expected().handle();
}
}
@@ -203,8 +203,9 @@ public class ShellView {
}
public void transferLocalFile(Path localPath, FilePath target) throws Exception {
long size = Files.size(localPath);
try (var in = Files.newInputStream(localPath)) {
writeStreamFile(target, in, in.available());
writeStreamFile(target, in, size);
}
}
@@ -225,7 +225,7 @@ public class TerminalDockView implements WindowDockListener {
TrackEvent.withTrace("Terminal view window shown").handle();
terminalInstances.forEach(terminalInstance -> {
var controllable = terminalInstance.getControllable();
if (controllable.isActive()) {
if (!controllable.isActive()) {
return;
}
@@ -104,14 +104,14 @@ public class FileBridge {
+ e.getLastModified());
if (e.registerChange()) {
event("Registering change for file " + TEMP.relativize(e.file) + " for editor entry " + e.getName());
var size = Files.size(e.file);
try (var in = Files.newInputStream(e.file)) {
var actualSize = (long) in.available();
var started = Instant.now();
var fixedIn = new FixedSizeInputStream(new BufferedInputStream(in), actualSize);
e.writer.accept(fixedIn, actualSize);
var fixedIn = new FixedSizeInputStream(new BufferedInputStream(in), size);
e.writer.accept(fixedIn, size);
in.transferTo(OutputStream.nullOutputStream());
var taken = Duration.between(started, Instant.now());
event("Wrote " + HumanReadableFormat.byteCount(actualSize) + " in " + taken.toMillis() + "ms");
event("Wrote " + HumanReadableFormat.byteCount(size) + " in " + taken.toMillis() + "ms");
} catch (NoSuchFileException ex) {
// The file might be removed meanwhile
ErrorEventFactory.fromThrowable(ex).expected().omit().handle();