Skip to content

Commit e55639d

Browse files
committed
Code refactor
1 parent c0374a3 commit e55639d

5 files changed

Lines changed: 13 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
### Features
55

6+
- **config:** Allow Scoop to ignore running processes during reset/uninstall/update ([#4713](https://github.com/ScoopInstaller/Scoop/issues/4713))
67
- **scoop-download:** Add `scoop download` command ([#4621](https://github.com/ScoopInstaller/Scoop/issues/4621))
78
- **scoop-(install|virustotal):** Allow skipping update check ([#4634](https://github.com/ScoopInstaller/Scoop/issues/4634))
89
- **scoop-bucket:** List more detailed information for buckets ([#4704](https://github.com/ScoopInstaller/Scoop/pull/4704))
@@ -14,7 +15,6 @@
1415
- **autoupdate:** Allow checksum file that contains whitespaces ([#4619](https://github.com/ScoopInstaller/Scoop/issues/4619))
1516
- **autoupdate:** Rename $response to $res ([#4706](https://github.com/ScoopInstaller/Scoop/issues/4706))
1617
- **config:** Allow scoop config use Unicode characters ([#4631](https://github.com/ScoopInstaller/Scoop/issues/4631))
17-
- **config:** Allow Scoop to ignore running processes during reset/uninstall/update ([#4713](https://github.com/ScoopInstaller/Scoop/issues/4713))
1818
- **config:** Fix `set_config` bugs ([#3681](https://github.com/ScoopInstaller/Scoop/issues/3681))
1919
- **current:** Remove 'current' while it's not a junction ([#4687](https://github.com/ScoopInstaller/Scoop/issues/4687))
2020
- **depends:** Prevent error on no URL ([#4595](https://github.com/ScoopInstaller/Scoop/issues/4595))

lib/install.ps1

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,20 +1212,16 @@ function persist_permission($manifest, $global) {
12121212
}
12131213
}
12141214

1215-
# return $true if running processes do not exist, or are handled by this function
1216-
function handle_running_processes($app, $global) {
1217-
$processdir = appdir $app $global | Resolve-Path | Select-Object -ExpandProperty Path
1215+
# test if there are running processes
1216+
function test_running_process($app, $global) {
1217+
$processdir = appdir $app $global | Convert-Path
12181218
$running_processes = Get-Process | Where-Object { $_.Path -like "$processdir\*" }
1219-
$ret = $true
12201219

1221-
if ($running_processes) {
1222-
$ret = get_config 'ignore_running_processes' $false
1223-
if ($ret) {
1224-
warn "Application `"$app`" is still running. Scoop is configured to ignore this condition."
1225-
} else {
1226-
error "Application `"$app`" is still running. Close all instances and try again."
1227-
}
1220+
if ($running_processes -and !(get_config 'ignore_running_processes')) {
1221+
error "Application `"$app`" is still running. Close all instances and try again."
1222+
return $true
1223+
} else {
1224+
warn "Application `"$app`" is still running. Scoop is configured to ignore this condition."
1225+
return $false
12281226
}
1229-
1230-
return $ret
12311227
}

libexec/scoop-reset.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ $apps | ForEach-Object {
6868
$persist_dir = persistdir $app $global
6969

7070
#region Workaround for #2952
71-
if (!(handle_running_processes $app $global)) {
71+
if (test_running_process $app $global) {
7272
continue
7373
}
7474
#endregion Workaround for #2952

libexec/scoop-uninstall.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ if (!$apps) { exit 0 }
5959
$persist_dir = persistdir $app $global
6060

6161
#region Workaround for #2952
62-
if (!(handle_running_processes $app $global)) {
62+
if (test_running_process $app $global) {
6363
continue
6464
}
6565
#endregion Workaround for #2952

libexec/scoop-update.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
231231
$persist_dir = persistdir $app $global
232232

233233
#region Workaround for #2952
234-
if (!(handle_running_processes $app $global)) {
234+
if (test_running_process $app $global) {
235235
return
236236
}
237237
#endregion Workaround for #2952

0 commit comments

Comments
 (0)