Skip to content

Commit 7900e98

Browse files
committed
fix bug: 1. installation lock; 2. expired state
1 parent b2d539f commit 7900e98

3 files changed

Lines changed: 32 additions & 5 deletions

File tree

installer/packages/com.datasafebox.client/meta/installscript.qs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,32 @@ Component.prototype.createOperations = function() {
6363
// its QtWebEngineProcess helper keeps e.g. resources/icudtl.dat
6464
// memory-mapped) or carry a read-only attribute; either aborts
6565
// extraction with "Can't unlink already-existing object: Permission
66-
// denied". Stop processes running from the target dir and clear
67-
// attributes before the archives are extracted.
66+
// denied". A fixed sleep after Stop-Process is a guess and does not
67+
// cover a lock held by something outside the target dir (antivirus
68+
// real-time scan, indexer, etc.), so this actually waits for our own
69+
// processes to exit and then verifies every existing file can be
70+
// opened exclusively before the archives are extracted, retrying
71+
// for a few seconds if something still holds a handle.
6872
var unlockScript =
6973
"$targetDir = " + psLiteral(toWindowsPath(targetDirRaw)) + "; " +
7074
"try { " +
7175
" if (Test-Path $targetDir) { " +
72-
" Get-Process -ErrorAction SilentlyContinue | Where-Object { $_.Path -and $_.Path.StartsWith(($targetDir.TrimEnd('\\') + '\\'), [StringComparison]::OrdinalIgnoreCase) } | Stop-Process -Force -ErrorAction SilentlyContinue; " +
73-
" Start-Sleep -Milliseconds 800; " +
74-
" attrib.exe -R ($targetDir.TrimEnd('\\') + '\\*') /S /D; " +
76+
" $prefix = $targetDir.TrimEnd('\\') + '\\'; " +
77+
" $procs = Get-Process -ErrorAction SilentlyContinue | Where-Object { $_.Path -and $_.Path.StartsWith($prefix, [StringComparison]::OrdinalIgnoreCase) }; " +
78+
" if ($procs) { " +
79+
" $procs | Stop-Process -Force -ErrorAction SilentlyContinue; " +
80+
" foreach ($p in $procs) { try { if (-not $p.HasExited) { $p.WaitForExit(5000) | Out-Null } } catch {} } " +
81+
" } " +
82+
" attrib.exe -R ($prefix + '*') /S /D; " +
83+
" $deadline = (Get-Date).AddSeconds(6); " +
84+
" do { " +
85+
" $locked = $false; " +
86+
" Get-ChildItem -Path $targetDir -Recurse -File -ErrorAction SilentlyContinue | ForEach-Object { " +
87+
" try { ([System.IO.File]::Open($_.FullName, 'Open', 'ReadWrite', 'None')).Close() } catch { $locked = $true } " +
88+
" }; " +
89+
" if (-not $locked) { break }; " +
90+
" Start-Sleep -Milliseconds 300; " +
91+
" } while ((Get-Date) -lt $deadline); " +
7592
" } " +
7693
"} catch {}; exit 0";
7794

qml/Logic/DomainUtils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function normalizeInstanceStatus(statusValue) {
3333
if (statusText === "2") return "已拒绝"
3434
if (statusText === "3") return "运行中"
3535
if (statusText === "4") return "已结束"
36+
if (statusText === "6") return "已过期"
3637
return statusText
3738
}
3839

qml/Theme/Colors.qml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ QtObject {
2020
readonly property string statusAuthorized: "已授权"
2121
readonly property string statusRejected: "已拒绝"
2222
readonly property string statusEnded: "已结束"
23+
readonly property string statusExpired: "已过期"
2324

2425
// Status colors
2526
readonly property var statusColors: ({
@@ -82,6 +83,12 @@ QtObject {
8283
border: "#e2e8f0",
8384
text: "#314158",
8485
dot: "#90A1B9"
86+
},
87+
"已过期": {
88+
bg: "#f1f5f9",
89+
border: "#e2e8f0",
90+
text: "#314158",
91+
dot: "#90A1B9"
8592
}
8693
})
8794
readonly property var defaultStatusColor: ({
@@ -181,6 +188,8 @@ QtObject {
181188
return qsTr("Rejected");
182189
if (s === "已结束")
183190
return qsTr("Ended");
191+
if (s === "已过期")
192+
return qsTr("Expired");
184193
return s;
185194
}
186195
}

0 commit comments

Comments
 (0)