Skip to content

Commit ea9961a

Browse files
Merge pull request #726 from ThePalaceProject/task/PP-3413-add-better-holds-error-reporting
Stability fixes: Crashlytics crashes, SAML sign-out, book persistence, CI improvements
2 parents 9d899ca + bdd7f31 commit ea9961a

File tree

235 files changed

+2323
-2048
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+2323
-2048
lines changed

.github/workflows/unit-testing.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jobs:
7979

8080
- name: Run Palace unit tests
8181
id: tests
82+
timeout-minutes: 20
8283
run: ./scripts/xcode-test-optimized.sh
8384
env:
8485
BUILD_CONTEXT: ci
@@ -89,35 +90,45 @@ jobs:
8990
id: find_results
9091
run: |
9192
echo "Looking for xcresult bundles..."
93+
echo "Current directory: $(pwd)"
94+
echo "Directory contents:"
95+
ls -la | head -20
9296
9397
# Check current directory
9498
if [ -d "TestResults.xcresult" ]; then
95-
echo "Found: ./TestResults.xcresult"
99+
echo "✅ Found: ./TestResults.xcresult"
100+
echo "xcresult size: $(du -sh TestResults.xcresult)"
96101
echo "path=TestResults.xcresult" >> $GITHUB_OUTPUT
97102
echo "found=true" >> $GITHUB_OUTPUT
103+
104+
# Quick check of what's inside
105+
echo "=== Quick xcresult summary ==="
106+
xcrun xcresulttool get test-results summary --path TestResults.xcresult 2>&1 | head -30 || echo "Could not get summary"
98107
exit 0
99108
fi
100109
101110
# Search in common locations
111+
echo "Searching for xcresult in current directory tree..."
102112
FOUND=$(find . -name "*.xcresult" -type d 2>/dev/null | head -1)
103113
if [ -n "$FOUND" ]; then
104-
echo "Found: $FOUND"
114+
echo "Found: $FOUND"
105115
echo "path=$FOUND" >> $GITHUB_OUTPUT
106116
echo "found=true" >> $GITHUB_OUTPUT
107117
exit 0
108118
fi
109119
110120
# Search in DerivedData
121+
echo "Searching in DerivedData..."
111122
FOUND=$(find ~/Library/Developer/Xcode/DerivedData -name "*.xcresult" -type d 2>/dev/null | head -1)
112123
if [ -n "$FOUND" ]; then
113-
echo "Found in DerivedData: $FOUND"
124+
echo "Found in DerivedData: $FOUND"
114125
cp -r "$FOUND" ./TestResults.xcresult
115126
echo "path=TestResults.xcresult" >> $GITHUB_OUTPUT
116127
echo "found=true" >> $GITHUB_OUTPUT
117128
exit 0
118129
fi
119130
120-
echo "No xcresult found"
131+
echo "No xcresult found anywhere!"
121132
echo "found=false" >> $GITHUB_OUTPUT
122133
123134
- name: Parse Test Results
@@ -141,6 +152,20 @@ jobs:
141152
142153
echo "Parsing test results from: $RESULT_PATH"
143154
155+
# Debug: Show raw xcresulttool output structure
156+
echo "=== xcresulttool version ==="
157+
xcrun xcresulttool version 2>/dev/null || echo "version command not available"
158+
159+
echo "=== Raw test-results summary (first 2000 chars) ==="
160+
xcrun xcresulttool get test-results summary --path "$RESULT_PATH" 2>/dev/null | head -c 2000 || echo "summary command failed"
161+
162+
echo ""
163+
echo "=== Raw test-results tests structure (first 3000 chars) ==="
164+
xcrun xcresulttool get test-results tests --path "$RESULT_PATH" 2>/dev/null | head -c 3000 || echo "tests command failed"
165+
166+
echo ""
167+
echo "=== Parsing with Python script ==="
168+
144169
# Use the enhanced Python parser - outputs to GITHUB_OUTPUT and test-data.json
145170
python3 scripts/parse-xcresult.py "$RESULT_PATH" --json test-data.json || true
146171

Palace.xcodeproj/project.pbxproj

Lines changed: 32 additions & 53 deletions
Large diffs are not rendered by default.

Palace.xcodeproj/xcshareddata/xcschemes/Palace.xcscheme

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,6 @@
171171
isEnabled = "YES">
172172
</EnvironmentVariable>
173173
</EnvironmentVariables>
174-
<AdditionalOptions>
175-
<AdditionalOption
176-
key = "PrefersMallocStackLoggingLite"
177-
value = ""
178-
isEnabled = "YES">
179-
</AdditionalOption>
180-
<AdditionalOption
181-
key = "MallocStackLogging"
182-
value = ""
183-
isEnabled = "YES">
184-
</AdditionalOption>
185-
</AdditionalOptions>
186174
<LocationScenarioReference
187175
identifier = "New York, NY, USA"
188176
referenceType = "1">

Palace/Accounts/Library/Account.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,14 @@ protocol AccountLogoDelegate: AnyObject {
245245
loansUrl = URL.init(string: authenticationDocument.links?.first(where: { $0.rel == "http://opds-spec.org/shelf" })?.href ?? "")
246246
supportsSimplyESync = userProfileUrl != nil
247247

248+
// Debug logging for sync support
249+
Log.debug(#file, """
250+
🔖 AccountDetails init for '\(authenticationDocument.title ?? "unknown")':
251+
userProfileUrl: \(userProfileUrl ?? "nil")
252+
supportsSimplyESync: \(supportsSimplyESync)
253+
Available links: \(authenticationDocument.links?.map { "[\($0.rel ?? "no-rel"): \($0.href ?? "no-href")]" }.joined(separator: ", ") ?? "none")
254+
""")
255+
248256
mainColor = authenticationDocument.colorScheme
249257

250258
let registerUrlStr = authenticationDocument.links?.first(where: { $0.rel == "register" })?.href

Palace/Accounts/User/TPPUserAccount.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,23 @@ private enum StorageKey: String {
399399

400400
return expirationDate <= Date() // Expired if date is in the past
401401
}
402+
403+
private enum TokenExpiry {
404+
static let refreshThresholdSeconds: TimeInterval = 300 // 5 minutes
405+
}
406+
407+
/// Returns true if the auth token exists and will expire within 5 minutes.
408+
/// Use this for proactive token refresh before making requests.
409+
var authTokenNearExpiry: Bool {
410+
guard let credentials = credentials,
411+
case let TPPCredentials.token(authToken: _, barcode: _, pin: _, expirationDate: expirationDate) = credentials,
412+
let expirationDate = expirationDate else {
413+
return false
414+
}
415+
416+
let expiryThreshold = Date().addingTimeInterval(TokenExpiry.refreshThresholdSeconds)
417+
return expirationDate <= expiryThreshold
418+
}
402419

403420
var patronFullName: String? {
404421
if let patron = patron,

0 commit comments

Comments
 (0)