Various fixes

This commit is contained in:
crschnick 2024-02-25 09:00:56 +00:00
parent d9db3b1ef6
commit 1a7a3637e6
5 changed files with 16 additions and 5 deletions

View file

@ -273,15 +273,15 @@ public class FileSystemHelper {
var baseRelative = FileNames.toDirectory(FileNames.getParent(source.getPath()));
List<FileSystem.FileEntry> 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) {

View file

@ -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')

View file

@ -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;

View file

@ -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;

View file

@ -17,6 +17,8 @@ import java.util.stream.Stream;
public interface FileSystem extends Closeable, AutoCloseable {
long getFileSize(String file) throws Exception;
FileSystemStore getStore();
Optional<ShellControl> getShell();