Various fixes

This commit is contained in:
crschnick 2025-04-04 09:25:47 +00:00
parent 1019f757e2
commit ee3d7642e2
12 changed files with 56 additions and 22 deletions

View file

@ -70,9 +70,9 @@ public final class BrowserFileListComp extends SimpleComp {
filenameCol.setReorderable(false);
filenameCol.setResizable(false);
var sizeCol = new TableColumn<BrowserEntry, Number>();
var sizeCol = new TableColumn<BrowserEntry, String>();
sizeCol.textProperty().bind(AppI18n.observable("size"));
sizeCol.setCellValueFactory(param -> new SimpleLongProperty(
sizeCol.setCellValueFactory(param -> new ReadOnlyStringWrapper(
param.getValue().getRawFileEntry().resolved().getSize()));
sizeCol.setCellFactory(col -> new FileSizeCell());
sizeCol.setResizable(false);
@ -579,19 +579,24 @@ public final class BrowserFileListComp extends SimpleComp {
}
}
private static class FileSizeCell extends TableCell<BrowserEntry, Number> {
private static class FileSizeCell extends TableCell<BrowserEntry, String> {
@Override
protected void updateItem(Number fileSize, boolean empty) {
protected void updateItem(String fileSize, boolean empty) {
super.updateItem(fileSize, empty);
if (empty || getTableRow() == null || getTableRow().getItem() == null) {
setText(null);
} else {
var path = getTableRow().getItem();
if (path.getRawFileEntry().resolved().getKind() == FileKind.DIRECTORY) {
setText("");
} else {
setText(byteCount(fileSize.longValue()));
setText(null);
} else if (fileSize != null) {
try {
var l = Long.parseLong(fileSize);
setText(byteCount(l));
} catch (NumberFormatException e) {
setText(fileSize);
}
}
}
}

View file

@ -127,7 +127,7 @@ public class BrowserFileSystemHelper {
fileSystem,
file,
Instant.now(),
fileSystem.getFileSize(file),
"" + fileSystem.getFileSize(file),
null,
fileSystem.directoryExists(file) ? FileKind.DIRECTORY : FileKind.FILE);
}

View file

@ -198,7 +198,7 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab<File
return null;
}
return new FileEntry(fileSystem, parent, null, 0, null, FileKind.DIRECTORY);
return new FileEntry(fileSystem, parent, null, null, null, FileKind.DIRECTORY);
}
public FileEntry getCurrentDirectory() {
@ -210,7 +210,7 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab<File
return null;
}
return new FileEntry(fileSystem, currentPath.get(), null, 0, null, FileKind.DIRECTORY);
return new FileEntry(fileSystem, currentPath.get(), null, null, null, FileKind.DIRECTORY);
}
public void cdAsync(FilePath path) {

View file

@ -267,11 +267,12 @@ public class BrowserFileTransferOperation {
return;
}
var rel = baseRelative.relativize(fileEntry.getPath()).toUnix().toString();
var rel = fileEntry.getPath().relativize(baseRelative).toUnix().toString();
flatFiles.put(fileEntry, rel);
if (fileEntry.getKind() == FileKind.FILE) {
// This one is up-to-date and does not need to be recalculated
totalSize.addAndGet(fileEntry.getSize());
// If we don't have a size, it doesn't matter that much as the total size is only for display
totalSize.addAndGet(fileEntry.getFileSizeLong().orElse(0));
}
}
} else {
@ -282,8 +283,8 @@ public class BrowserFileTransferOperation {
}
flatFiles.put(source, source.getPath().getFileName());
// Recalculate as it could have been changed meanwhile
totalSize.addAndGet(source.getFileSystem().getFileSize(source.getPath()));
// If we don't have a size, it doesn't matter that much as the total size is only for display
totalSize.addAndGet(source.getFileSizeLong().orElse(0));
}
var start = Instant.now();
@ -421,7 +422,7 @@ public class BrowserFileTransferOperation {
var thread = ThreadHelper.createPlatformThread("transfer", true, () -> {
try {
long readCount = 0;
var bs = (int) Math.min(DEFAULT_BUFFER_SIZE, sourceFile.getSize());
var bs = (int) Math.min(DEFAULT_BUFFER_SIZE, expectedFileSize);
byte[] buffer = new byte[bs];
int read;
while ((read = inputStream.read(buffer, 0, bs)) > 0) {

View file

@ -36,7 +36,7 @@ public class BrowserLocalFileSystem {
localFileSystem.open(),
FilePath.of(file),
Files.getLastModifiedTime(file).toInstant(),
Files.size(file),
"" + Files.size(file),
null,
Files.isDirectory(file) ? FileKind.DIRECTORY : FileKind.FILE);
}

View file

@ -88,7 +88,7 @@ public class BrowserStatusBarComp extends SimpleComp {
} else {
var expected = p.expectedTimeRemaining();
var show = p.elapsedTime().compareTo(Duration.of(200, ChronoUnit.MILLIS)) > 0
&& (p.getTotal() > 50_000_000 || expected.toMillis() > 5000);
&& (!p.hasKnownTotalSize() || p.getTotal() > 50_000_000 || expected.toMillis() > 5000);
var time = show ? HumanReadableFormat.duration(p.expectedTimeRemaining()) : "";
return time;
}
@ -106,6 +106,10 @@ public class BrowserStatusBarComp extends SimpleComp {
return null;
} else {
var transferred = HumanReadableFormat.progressByteCount(p.getTransferred());
if (!p.hasKnownTotalSize()) {
return transferred;
}
var all = HumanReadableFormat.byteCount(p.getTotal());
return transferred + " / " + all;
}

View file

@ -65,6 +65,10 @@ public class BrowserTransferComp extends SimpleComp {
return Bindings.createStringBinding(
() -> {
var p = sourceItem.get().getProgress().getValue();
if (!p.hasKnownTotalSize()) {
return entry.getFileName();
}
var hideProgress =
sourceItem.get().downloadFinished().get();
var share = p != null ? (p.getTransferred() * 100 / p.getTotal()) : 0;

View file

@ -22,6 +22,10 @@ public class BrowserTransferProgress {
return transferred >= total;
}
public boolean hasKnownTotalSize() {
return total > 0;
}
public Duration elapsedTime() {
var now = Instant.now();
var elapsed = Duration.between(start, now);

View file

@ -6,13 +6,14 @@ import lombok.Value;
import lombok.experimental.NonFinal;
import java.time.Instant;
import java.util.OptionalLong;
@Value
@NonFinal
public class FileEntry {
FileSystem fileSystem;
Instant date;
long size;
String size;
FileInfo info;
@ -28,7 +29,7 @@ public class FileEntry {
FileSystem fileSystem,
@NonNull FilePath path,
Instant date,
long size,
String size,
FileInfo info,
@NonNull FileKind kind) {
this.fileSystem = fileSystem;
@ -40,7 +41,20 @@ public class FileEntry {
}
public static FileEntry ofDirectory(FileSystem fileSystem, FilePath path) {
return new FileEntry(fileSystem, path, Instant.now(), 0, null, FileKind.DIRECTORY);
return new FileEntry(fileSystem, path, Instant.now(), null, null, FileKind.DIRECTORY);
}
public OptionalLong getFileSizeLong() {
if (size == null) {
return OptionalLong.empty();
}
try {
var l = Long.parseLong(size);
return OptionalLong.of(l);
} catch (NumberFormatException e) {
return OptionalLong.empty();
}
}
public FileEntry resolved() {

View file

@ -40,7 +40,7 @@ public sealed interface FileInfo permits FileInfo.Windows, FileInfo.Unix {
@Override
public boolean possiblyExecutable() {
return permissions.contains("x");
return permissions == null || permissions.contains("x");
}
}
}

View file

@ -17,7 +17,7 @@ public class LinkFileEntry extends FileEntry {
FileSystem fileSystem,
@NonNull FilePath path,
Instant date,
long size,
String size,
@NonNull FileInfo info,
@NonNull FileEntry target) {
super(fileSystem, path, date, size, info, FileKind.LINK);

View file

@ -31,6 +31,7 @@ The password manager integration has been improved and made more robust:
- The SSH gateway implementation has been reworked so that you can now use local SSH keys and other identities for connections with gateways
- Generated connection names, e.g. VM names, will now automatically update on refresh when they were changed
- You can now unlock the vault with your password manager
- Various speed improvements for shell operations
- Various startup speed improvements
- The scripts context menu now shows the respective scripts icons instead of generic ones
@ -41,6 +42,7 @@ The password manager integration has been improved and made more robust:
## Fixes
- Fix various embedded and busybox systems failing to open in file browser when essential commands like stat were missing
- Fix Windows msi updates failing when initial installation was installed per-user as an Administrator
- Fix Windows msi updates launching XPipe as Administrator when restarting if it was a system-wide program files installation
- Fix some dialog content shifting around on initial show