mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 09:00:26 +00:00
Improve file transfer resilience
This commit is contained in:
parent
7c6906d86e
commit
07caa29262
1 changed files with 8 additions and 1 deletions
|
@ -95,8 +95,15 @@ public class FileBridge {
|
|||
if (e.hasChanged()) {
|
||||
event("Registering change for file " + TEMP.relativize(e.file) + " for editor entry " + e.getName());
|
||||
e.registerChange();
|
||||
var expectedSize = Files.size(e.file);
|
||||
try (var in = Files.newInputStream(e.file)) {
|
||||
e.writer.accept(in, (long) in.available());
|
||||
var actualSize = (long) in.available();
|
||||
if (expectedSize != actualSize) {
|
||||
event("Expected file size " + expectedSize + " but got size " + actualSize + ". Ignoring change ...");
|
||||
return;
|
||||
}
|
||||
|
||||
e.writer.accept(in, actualSize);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
|
Loading…
Reference in a new issue