fix (#195) & opt.

- fix: debug provider color
- fix: can't write script through SFTP (#195)
- opt.: go next refresh only after current refresh task is done
This commit is contained in:
lollipopkit
2023-10-30 12:01:07 +08:00
parent eb0b219505
commit 2b52e8e6ee
6 changed files with 72 additions and 42 deletions

View File

@@ -5,13 +5,7 @@ const seperator = 'SrvBoxSep';
/// The suffix `\t` is for formatting
const _cmdDivider = '\necho $seperator\n\t';
const _serverBoxDir = r'$HOME/.config/server_box';
/// Issue #159
/// Use script commit count as version of shell script.
/// So different version of app can run at the same time.
const installShellPath = '$_serverBoxDir/mobile_v${BuildData.script}.sh';
const _homeVar = '\$HOME';
enum ShellFunc {
status,
@@ -22,6 +16,31 @@ enum ShellFunc {
suspend,
;
static const _serverBoxDir = '.config/server_box';
static const _scriptFileName = 'mobile_v${BuildData.script}.sh';
/// Issue #159
///
/// Use script commit count as version of shell script.
///
/// So different version of app can run at the same time.
///
/// **Can't** use it in SFTP, because SFTP can't recognize `$HOME`
static String getShellPath(String home) =>
'$home/$_serverBoxDir/$_scriptFileName';
static final _installShellPath = getShellPath(_homeVar);
/// Issue #168
/// Use `sh` for compatibility
static final installShellCmd = """
mkdir -p $_homeVar/$_serverBoxDir
cat << 'EOF' > $_installShellPath
${ShellFunc.allScript}
EOF
chmod +x $_installShellPath
""";
String get flag {
switch (this) {
case ShellFunc.status:
@@ -39,7 +58,7 @@ enum ShellFunc {
}
}
String get exec => 'sh $installShellPath -$flag';
String get exec => 'sh $_installShellPath -$flag';
String get name {
switch (this) {
@@ -241,13 +260,3 @@ const _bsdStatusCmd = [
//'sysctl -a | grep temperature',
'hostname',
];
/// Issue #168
/// Use `sh` for compatibility
final installShellCmd = """
mkdir -p $_serverBoxDir
cat << 'EOF' > $installShellPath
${ShellFunc.allScript}
EOF
chmod +x $installShellPath
""";

View File

@@ -10,9 +10,8 @@ class Server implements TagPickable {
SSHClient? client;
ServerState state;
/// Whether is generating client.
/// Use this to avoid reconnecting if last connect try not finished.
bool isGenerating = false;
/// Whether is connectting, parsing and etc.
bool isBusy = false;
Server(this.spi, this.status, this.client, this.state);