mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 09:00:26 +00:00
Improve shell control bookkeeping
This commit is contained in:
parent
acb2583100
commit
dd542d6758
7 changed files with 28 additions and 6 deletions
|
@ -19,6 +19,13 @@ public class LocalFileSystem {
|
|||
}
|
||||
}
|
||||
|
||||
public static void reset() throws Exception {
|
||||
if (localFileSystem != null) {
|
||||
localFileSystem.close();
|
||||
localFileSystem = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static FileEntry getLocalFileEntry(Path file) throws Exception {
|
||||
if (localFileSystem == null) {
|
||||
throw new IllegalStateException();
|
||||
|
|
|
@ -72,10 +72,11 @@ public final class OpenFileSystemModel extends BrowserSessionTab<FileSystemStore
|
|||
|
||||
@Override
|
||||
public boolean canImmediatelyClose() {
|
||||
return (progress.getValue() == null || progress.getValue().done())
|
||||
|| (fileSystem != null
|
||||
&& fileSystem.getShell().isPresent()
|
||||
&& fileSystem.getShell().get().getLock().isLocked());
|
||||
if (fileSystem == null || fileSystem.getShell().isEmpty() || !fileSystem.getShell().get().getLock().isLocked()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return progress.getValue() == null || progress.getValue().done();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -51,7 +51,7 @@ public class BrowserSessionModel extends BrowserAbstractSessionModel<BrowserSess
|
|||
for (var o : new ArrayList<>(sessionEntries)) {
|
||||
// Don't close busy connections gracefully
|
||||
// as we otherwise might lock up
|
||||
if (o.canImmediatelyClose()) {
|
||||
if (!o.canImmediatelyClose()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import io.xpipe.app.core.*;
|
|||
import io.xpipe.app.core.check.*;
|
||||
import io.xpipe.app.ext.ActionProvider;
|
||||
import io.xpipe.app.ext.DataStoreProviders;
|
||||
import io.xpipe.app.ext.ProcessControlProvider;
|
||||
import io.xpipe.app.issue.TrackEvent;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.resources.AppResources;
|
||||
|
@ -74,7 +75,7 @@ public class BaseMode extends OperationMode {
|
|||
public void onSwitchFrom() {}
|
||||
|
||||
@Override
|
||||
public void finalTeardown() {
|
||||
public void finalTeardown() throws Exception {
|
||||
TrackEvent.info("Background mode shutdown started");
|
||||
BrowserSessionModel.DEFAULT.reset();
|
||||
SshLocalBridge.reset();
|
||||
|
@ -82,6 +83,9 @@ public class BaseMode extends OperationMode {
|
|||
DataStoreProviders.reset();
|
||||
DataStorage.reset();
|
||||
AppPrefs.reset();
|
||||
DataStorageSyncHandler.getInstance().reset();
|
||||
LocalShell.reset();
|
||||
ProcessControlProvider.get().reset();
|
||||
AppResources.reset();
|
||||
AppExtensionManager.reset();
|
||||
AppDataLock.unlock();
|
||||
|
|
|
@ -63,4 +63,10 @@ public class GuiMode extends PlatformMode {
|
|||
|
||||
UpdateChangelogAlert.showIfNeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalTeardown() throws Throwable {
|
||||
LocalFileSystem.reset();
|
||||
super.finalTeardown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ public abstract class ProcessControlProvider {
|
|||
return INSTANCE;
|
||||
}
|
||||
|
||||
public abstract void reset();
|
||||
|
||||
public abstract ShellControl withDefaultScripts(ShellControl pc);
|
||||
|
||||
public abstract ShellControl sub(
|
||||
|
|
|
@ -10,6 +10,8 @@ public interface DataStorageSyncHandler {
|
|||
return (DataStorageSyncHandler) ProcessControlProvider.get().getGitStorageHandler();
|
||||
}
|
||||
|
||||
void reset() throws Exception;
|
||||
|
||||
boolean validateConnection();
|
||||
|
||||
boolean supportsSync();
|
||||
|
|
Loading…
Reference in a new issue