@electerm/electerm-react 3.8.6 → 3.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,6 +63,7 @@ export default auto(function SettingModalWrap (props) {
63
63
  ...props0,
64
64
  bookmarkSelectMode,
65
65
  bookmarkGroups,
66
+ bookmarkGroupTree: store.bookmarkGroupTree,
66
67
  bookmarksMap: store.bookmarksMap,
67
68
  bookmarks,
68
69
  ...pick(store, [
@@ -46,6 +46,11 @@ export default class FileMode extends React.PureComponent {
46
46
  }
47
47
 
48
48
  showFileInfoModal (data) {
49
+ if (data.pid !== this.remoteExecPid) {
50
+ this.remoteExecPid = data.pid
51
+ this.remoteExecPlatform = null
52
+ this.remoteExecPlatformPromise = null
53
+ }
49
54
  this.setStateProxy({
50
55
  ...data,
51
56
  size: 0,
@@ -115,6 +120,47 @@ export default class FileMode extends React.PureComponent {
115
120
  }
116
121
  }
117
122
 
123
+ escapePowerShellPath = (value) => {
124
+ return String(value).replace(/'/g, "''")
125
+ }
126
+
127
+ normalizeRemoteWindowsPath = (value) => {
128
+ return String(value).replace(/^\/([a-zA-Z]:)/, '$1')
129
+ }
130
+
131
+ getRemoteExecPlatform = async () => {
132
+ if (this.remoteExecPid === this.state.pid && this.remoteExecPlatform) {
133
+ return this.remoteExecPlatform
134
+ }
135
+ if (this.remoteExecPid !== this.state.pid) {
136
+ this.remoteExecPid = this.state.pid
137
+ this.remoteExecPlatform = null
138
+ this.remoteExecPlatformPromise = null
139
+ }
140
+ if (!this.remoteExecPlatformPromise) {
141
+ this.remoteExecPlatformPromise = runCmd(this.state.pid, 'cmd.exe /d /s /c ver')
142
+ .then(output => {
143
+ return String(output).toLowerCase().includes('windows')
144
+ ? 'windows'
145
+ : 'posix'
146
+ })
147
+ .catch(() => 'posix')
148
+ .then(platform => {
149
+ this.remoteExecPlatform = platform
150
+ return platform
151
+ })
152
+ }
153
+ return this.remoteExecPlatformPromise
154
+ }
155
+
156
+ calcRemoteWin = async (folder) => {
157
+ const winFolder = this.normalizeRemoteWindowsPath(folder)
158
+ const escapedFolder = this.escapePowerShellPath(winFolder)
159
+ const cmd = `powershell.exe -NoLogo -NonInteractive -NoProfile -Command "$result = Get-ChildItem -LiteralPath '${escapedFolder}' -Recurse -File | Measure-Object -Property Length -Sum; if ($null -eq $result.Sum) { 0 } else { [int64]$result.Sum }"`
160
+ const result = await runCmd(this.state.pid, cmd).catch(window.store.onError)
161
+ return filesize(parseInt(String(result || '').trim(), 10) || 0)
162
+ }
163
+
118
164
  calcLocal = async (folder) => {
119
165
  const cmd = isWin
120
166
  ? `Get-ChildItem -Recurse '${folder}' | Measure-Object -Property Length -Sum`
@@ -125,6 +171,10 @@ export default class FileMode extends React.PureComponent {
125
171
  }
126
172
 
127
173
  calcRemote = async (folder) => {
174
+ const platform = await this.getRemoteExecPlatform()
175
+ if (platform === 'windows') {
176
+ return this.calcRemoteWin(folder)
177
+ }
128
178
  const cmd = `du -sh '${folder}'`
129
179
  const r = await runCmd(
130
180
  this.state.pid,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "3.8.6",
3
+ "version": "3.8.8",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",