Skip to content

Commit 737b2c4

Browse files
author
阿绿
committed
PullRequest: 37 chore: check work directory
Merge branch opt_check_dir of [email protected]:oceanbase/OBShell-SDK-Python.git into master https://code.alipay.com/oceanbase/OBShell-SDK-Python/pull_requests/37 Signed-off-by: 玉楼 <[email protected]> * opt
1 parent 920b2eb commit 737b2c4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

obshell/ssh.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ def _sftp_write_file(self, context, remote_file_path, mode=0o644):
250250

251251
def check_remote_dir_empty(client: SshClient, work_dir: str):
252252
logger.debug(f"Check remote directory: {work_dir}")
253-
ret = client.execute(f'if [ -d {work_dir} ]; then ls -A {work_dir}; fi')
254-
return ret and len(ret.stdout) == 0
253+
return client.execute(f'![ -e {work_dir} ] || [ "$(ls -A {work_dir} 2>/dev/null | wc -l)" -eq 0 ]')
255254

256255

257256
def check_observer_version(client: SshClient, work_dir: str):

0 commit comments

Comments
 (0)