mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Improve os detection and file existance checks
This commit is contained in:
parent
4726ad975c
commit
fe396e1b11
8 changed files with 10 additions and 9 deletions
|
@ -74,7 +74,7 @@ public class AppInstaller {
|
|||
}
|
||||
|
||||
if (p.getOsType().equals(OsType.LINUX)) {
|
||||
try (CommandControl c = p.command(p.getShellDialect().getFileExistsCommand("/etc/debian_version"))
|
||||
try (CommandControl c = p.getShellDialect().createFileExistsCommand(p, "/etc/debian_version")
|
||||
.start()) {
|
||||
return c.discardAndCheckExit() ? new InstallerAssetType.Debian() : new InstallerAssetType.Rpm();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class ProxyManagerProviderImpl extends ProxyManagerProvider {
|
|||
var defaultInstallationExecutable = FileNames.join(
|
||||
XPipeInstallation.getDefaultInstallationBasePath(s, false),
|
||||
XPipeInstallation.getDaemonExecutablePath(s.getOsType()));
|
||||
if (!s.executeBooleanSimpleCommand(s.getShellDialect().getFileExistsCommand(defaultInstallationExecutable))) {
|
||||
if (!s.getShellDialect().createFileExistsCommand(s, defaultInstallationExecutable).executeAndCheck()) {
|
||||
return Optional.of(AppI18n.get("noInstallationFound"));
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ public class FileStore extends JacksonizedValue implements FilenameStore, Stream
|
|||
|
||||
@Override
|
||||
public boolean canOpen() throws Exception {
|
||||
return fileSystem.createFileSystem().open().exists(path);
|
||||
return fileSystem.createFileSystem().open().fileExists(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -123,7 +123,7 @@ public interface ShellDialect {
|
|||
|
||||
String getFileDeleteCommand(String file);
|
||||
|
||||
String getFileExistsCommand(String file);
|
||||
CommandControl createFileExistsCommand(ShellControl sc, String file);
|
||||
|
||||
String getFileTouchCommand(String file);
|
||||
|
||||
|
|
|
@ -76,9 +76,9 @@ public class ConnectionFileSystem implements FileSystem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(String file) throws Exception {
|
||||
try (var pc = shellControl.command(proc -> proc.getShellDialect()
|
||||
.getFileExistsCommand(file)).complex()
|
||||
public boolean fileExists(String file) throws Exception {
|
||||
try (var pc = shellControl.getShellDialect()
|
||||
.createFileExistsCommand(shellControl, file).complex()
|
||||
.start()) {
|
||||
return pc.discardAndCheckExit();
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public interface FileSystem extends Closeable, AutoCloseable {
|
|||
|
||||
OutputStream openOutput(String file) throws Exception;
|
||||
|
||||
public boolean exists(String file) throws Exception;
|
||||
public boolean fileExists(String file) throws Exception;
|
||||
|
||||
public void delete(String file) throws Exception;
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ public class XPipeSession {
|
|||
: UuidHelper.parse(() -> Files.readString(sessionFile)).orElse(UUID.randomUUID());
|
||||
|
||||
try {
|
||||
//TODO: People might move their page file to another drive
|
||||
if (OsType.getLocal().equals(OsType.WINDOWS)) {
|
||||
var pf = Path.of("C:\\pagefile.sys");
|
||||
BasicFileAttributes attr = Files.readAttributes(pf, BasicFileAttributes.class);
|
||||
|
|
|
@ -23,7 +23,7 @@ public class XPipeTempDirectory {
|
|||
var base = proc.getOsType().getTempDirectory(proc);
|
||||
var dir = FileNames.join(base, "xpipe");
|
||||
|
||||
if (!proc.executeBooleanSimpleCommand(proc.getShellDialect().getFileExistsCommand(dir))) {
|
||||
if (!proc.getShellDialect().createFileExistsCommand(proc, dir).executeAndCheck()) {
|
||||
proc.executeSimpleCommand(proc.getShellDialect().getMkdirsCommand(dir),
|
||||
"Unable to access or create temporary directory " + dir);
|
||||
|
||||
|
|
Loading…
Reference in a new issue