Skip to content

Commit 5e1a2ae

Browse files
leogdionclaude
andcommitted
refactor: improve VirtualBuddy fetcher logging and rate limiting
- Streamline logging to show only results (signed/unsigned status or errors) - Add visual status indicators (✅/❌) for signing status - Include progress counter in all log messages for consistency - Refine random delay to 2.5-3.5 seconds with 1-second tolerance - Remove obsolete add-env-to-scheme.sh script - Update CLAUDE.md to reflect improved timing and performance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 54221b3 commit 5e1a2ae

File tree

3 files changed

+11
-87
lines changed

3 files changed

+11
-87
lines changed

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ GET https://tss.virtualbuddy.app/v1/status?apiKey=<key>&ipsw=<IPSW URL>
182182
**Rate Limits & Caching**:
183183
- **Rate limit**: 2 requests per 5 seconds
184184
- **Server-side CDN cache**: 12 hours (to avoid Apple TSS rate limiting)
185-
- **Client-side implementation**: Random delays of 2.5-5.0 seconds between requests
185+
- **Client-side implementation**: Random delays of 2.5-3.5 seconds with 1-second tolerance between requests
186186

187187
**Implementation Details**:
188188
- **File**: `Sources/BushelCloudKit/DataSources/VirtualBuddyFetcher.swift`
189189
- **Integration**: Enriches RestoreImageRecord with real-time signing status after other data sources
190190
- **Error handling**: HTTP 429 errors are logged; original record preserved on any error
191191
- **Progress tracking**: Shows "X/Y images checked" during sync
192-
- **Performance**: ~3-4 minutes for 50 images (acceptable for 8-16 hour sync schedules)
192+
- **Performance**: ~2.5-4 minutes for 50 images (acceptable for 8-16 hour sync schedules)
193193

194194
**Deduplication Priority**:
195195
- VirtualBuddy is an **authoritative source** for `isSigned` status (along with MESU)

Scripts/add-env-to-scheme.sh

Lines changed: 0 additions & 80 deletions
This file was deleted.

Sources/BushelCloudKit/DataSources/VirtualBuddyFetcher.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,14 @@ struct VirtualBuddyFetcher: DataSourceFetcher, Sendable {
9292
}
9393

9494
processedCount += 1
95-
print(" 🔍 VirtualBuddy: \(image.buildNumber) (\(processedCount)/\(totalCount))")
9695

9796
do {
9897
let response = try await checkSigningStatus(for: image.downloadURL)
9998

10099
// Validate build number matches
101100
guard response.build == image.buildNumber else {
102101
print(
103-
" ⚠️ VirtualBuddy build mismatch: expected \(image.buildNumber), got \(response.build)"
102+
" ⚠️ VirtualBuddy: \(image.buildNumber) - build mismatch: expected \(image.buildNumber), got \(response.build) (\(processedCount)/\(totalCount))"
104103
)
105104
enrichedImages.append(image)
106105
continue
@@ -113,17 +112,22 @@ struct VirtualBuddyFetcher: DataSourceFetcher, Sendable {
113112
enriched.sourceUpdatedAt = Date() // Real-time TSS check
114113
enriched.notes = response.message // TSS status message
115114

115+
// Show result with signing status
116+
let statusEmoji = response.isSigned ? "" : ""
117+
let statusText = response.isSigned ? "signed" : "unsigned"
118+
print(" \(statusEmoji) VirtualBuddy: \(image.buildNumber) - \(statusText) (\(processedCount)/\(totalCount))")
119+
116120
enrichedImages.append(enriched)
117121
} catch {
118-
print(" ⚠️ VirtualBuddy error for \(image.buildNumber): \(error)")
122+
print(" ⚠️ VirtualBuddy: \(image.buildNumber) - error: \(error) (\(processedCount)/\(totalCount))")
119123
enrichedImages.append(image) // Keep original on error
120124
}
121125

122126
// Add random delay between requests to respect rate limit (2 req/5 sec)
123127
// Only delay if there are more images to process
124128
if processedCount < totalCount {
125-
let randomDelay = Double.random(in: 2.5...5.0)
126-
try await Task.sleep(for: .seconds(randomDelay))
129+
let randomDelay = Double.random(in: 2.5...3.5)
130+
try await Task.sleep(for: .seconds(randomDelay), tolerance: .seconds(1))
127131
}
128132
}
129133

0 commit comments

Comments
 (0)