From 1a7a3637e6bc425f63c991c7ff8951b0720cf39f Mon Sep 17 00:00:00 2001 From: crschnick Date: Sun, 25 Feb 2024 09:00:56 +0000 Subject: [PATCH] Various fixes --- .../java/io/xpipe/app/browser/FileSystemHelper.java | 11 ++++++----- build.gradle | 1 + .../main/java/io/xpipe/core/process/ShellDialect.java | 2 ++ .../io/xpipe/core/store/ConnectionFileSystem.java | 5 +++++ .../src/main/java/io/xpipe/core/store/FileSystem.java | 2 ++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java b/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java index 39b973de4..a6e7f0a3b 100644 --- a/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java +++ b/app/src/main/java/io/xpipe/app/browser/FileSystemHelper.java @@ -273,15 +273,15 @@ public class FileSystemHelper { var baseRelative = FileNames.toDirectory(FileNames.getParent(source.getPath())); List list = source.getFileSystem().listFilesRecursively(source.getPath()); - list.forEach(fileEntry -> { + for (FileSystem.FileEntry fileEntry : list) { flatFiles.put(fileEntry, FileNames.toUnix(FileNames.relativize(baseRelative, fileEntry.getPath()))); if (fileEntry.getKind() == FileKind.FILE) { - totalSize.addAndGet(fileEntry.getSize()); + totalSize.addAndGet(fileEntry.getFileSystem().getFileSize(fileEntry.getPath())); } - }); + } } else { flatFiles.put(source, FileNames.getFileName(source.getPath())); - totalSize.addAndGet(source.getSize()); + totalSize.addAndGet(source.getFileSystem().getFileSize(source.getPath())); } AtomicLong transferred = new AtomicLong(); @@ -303,8 +303,9 @@ public class FileSystemHelper { InputStream inputStream = null; OutputStream outputStream = null; try { + var fileSize = sourceFile.getFileSystem().getFileSize(sourceFile.getPath()); inputStream = sourceFile.getFileSystem().openInput(sourceFile.getPath()); - outputStream = target.getFileSystem().openOutput(targetFile, sourceFile.getSize()); + outputStream = target.getFileSystem().openOutput(targetFile, fileSize); transferFile(sourceFile, inputStream, outputStream, transferred, totalSize, progress); inputStream.transferTo(OutputStream.nullOutputStream()); } catch (Exception ex) { diff --git a/build.gradle b/build.gradle index 4728479b1..48a7b3ea3 100644 --- a/build.gradle +++ b/build.gradle @@ -57,6 +57,7 @@ project.ext { arch = getArchName() privateExtensions = file("$rootDir/private_extensions.txt").exists() ? file("$rootDir/private_extensions.txt").readLines() : [] isFullRelease = System.getenv('RELEASE') != null && Boolean.parseBoolean(System.getenv('RELEASE')) + isPreRelease = System.getenv('PRERELEASE') != null && Boolean.parseBoolean(System.getenv('PRERELEASE')) isStage = System.getenv('STAGE') != null && Boolean.parseBoolean(System.getenv('STAGE')) rawVersion = file('version').text.trim() versionString = rawVersion + (isFullRelease || isStage ? '' : '-SNAPSHOT') diff --git a/core/src/main/java/io/xpipe/core/process/ShellDialect.java b/core/src/main/java/io/xpipe/core/process/ShellDialect.java index 381fba0d1..1befc59e6 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellDialect.java +++ b/core/src/main/java/io/xpipe/core/process/ShellDialect.java @@ -35,6 +35,8 @@ public interface ShellDialect { String queryVersion(ShellControl shellControl) throws Exception; + CommandControl queryFileSize(ShellControl shellControl, String file); + CommandControl prepareUserTempDirectory(ShellControl shellControl, String directory); String initFileName(ShellControl sc) throws Exception; diff --git a/core/src/main/java/io/xpipe/core/store/ConnectionFileSystem.java b/core/src/main/java/io/xpipe/core/store/ConnectionFileSystem.java index 776b2e65d..7290cdd02 100644 --- a/core/src/main/java/io/xpipe/core/store/ConnectionFileSystem.java +++ b/core/src/main/java/io/xpipe/core/store/ConnectionFileSystem.java @@ -25,6 +25,11 @@ public class ConnectionFileSystem implements FileSystem { this.store = store; } + @Override + public long getFileSize(String file) throws Exception { + return Long.parseLong(shellControl.getShellDialect().queryFileSize(shellControl, file).readStdoutOrThrow()); + } + @Override public FileSystemStore getStore() { return store; diff --git a/core/src/main/java/io/xpipe/core/store/FileSystem.java b/core/src/main/java/io/xpipe/core/store/FileSystem.java index b1e6b7c2c..f7e89216e 100644 --- a/core/src/main/java/io/xpipe/core/store/FileSystem.java +++ b/core/src/main/java/io/xpipe/core/store/FileSystem.java @@ -17,6 +17,8 @@ import java.util.stream.Stream; public interface FileSystem extends Closeable, AutoCloseable { + long getFileSize(String file) throws Exception; + FileSystemStore getStore(); Optional getShell();