Skip to content

Commit 4b6ebd4

Browse files
committed
Remove debug print statements
1 parent 1d6093b commit 4b6ebd4

File tree

2 files changed

+0
-36
lines changed

2 files changed

+0
-36
lines changed

Sources/Hub/Downloader.swift

-32
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class Downloader: NSObject, ObservableObject {
5353
if let attributes = try? FileManager.default.attributesOfItem(atPath: incompletePath.path),
5454
let fileSize = attributes[.size] as? Int
5555
{
56-
print("[Downloader] Found existing incomplete file for \(destination.lastPathComponent): \(fileSize) bytes")
5756
return fileSize
5857
}
5958
}
@@ -122,19 +121,13 @@ class Downloader: NSObject, ObservableObject {
122121
timeout: TimeInterval,
123122
numRetries: Int
124123
) {
125-
print("[Downloader] Setting up download for \(url.lastPathComponent)")
126-
print("[Downloader] Destination: \(destination.path)")
127-
print("[Downloader] Incomplete file: \(tempFilePath?.path ?? "none")")
128-
129124
urlSession?.getAllTasks { tasks in
130125
// If there's an existing pending background task with the same URL, let it proceed.
131126
if let existing = tasks.filter({ $0.originalRequest?.url == url }).first {
132127
switch existing.state {
133128
case .running:
134-
print("[Downloader] Task already running for \(url.lastPathComponent)")
135129
return
136130
case .suspended:
137-
print("[Downloader] Resuming suspended download task for \(url.lastPathComponent)")
138131
existing.resume()
139132
return
140133
case .canceling, .completed:
@@ -156,15 +149,13 @@ class Downloader: NSObject, ObservableObject {
156149
if fileManager.fileExists(atPath: incompleteFilePath.path) {
157150
let attributes = try fileManager.attributesOfItem(atPath: incompleteFilePath.path)
158151
existingSize = attributes[.size] as? Int ?? 0
159-
print("[Downloader] Found incomplete file with \(existingSize) bytes")
160152
self.downloadedSize = existingSize
161153
} else {
162154
// Create parent directory if needed
163155
try fileManager.createDirectory(at: incompleteFilePath.deletingLastPathComponent(), withIntermediateDirectories: true)
164156

165157
// Create empty incomplete file
166158
fileManager.createFile(atPath: incompleteFilePath.path, contents: nil)
167-
print("[Downloader] Created new incomplete file at \(incompleteFilePath.path)")
168159
}
169160

170161
// Set up the request with appropriate headers
@@ -183,14 +174,11 @@ class Downloader: NSObject, ObservableObject {
183174
if let expectedSize, expectedSize > 0 {
184175
let initialProgress = Double(existingSize) / Double(expectedSize)
185176
self.downloadState.value = .downloading(initialProgress)
186-
print("[Downloader] Resuming from \(existingSize)/\(expectedSize) bytes (\(Int(initialProgress * 100))%)")
187177
} else {
188178
self.downloadState.value = .downloading(0)
189-
print("[Downloader] Resuming download from byte \(existingSize)")
190179
}
191180
} else {
192181
self.downloadState.value = .downloading(0)
193-
print("[Downloader] Starting new download")
194182
}
195183

196184
request.timeoutInterval = timeout
@@ -209,14 +197,9 @@ class Downloader: NSObject, ObservableObject {
209197

210198
// Clean up and move the completed download to its final destination
211199
tempFile.closeFile()
212-
print("[Downloader] Download completed with total size \(self.downloadedSize) bytes")
213-
print("[Downloader] Moving incomplete file to destination: \(self.destination.path)")
214200
try fileManager.moveDownloadedFile(from: incompleteFilePath, to: self.destination)
215-
216-
print("[Downloader] Download successfully completed")
217201
self.downloadState.value = .completed(self.destination)
218202
} catch {
219-
print("[Downloader] Error: \(error)")
220203
self.downloadState.value = .failed(error)
221204
}
222205
}
@@ -249,27 +232,15 @@ class Downloader: NSObject, ObservableObject {
249232
var newRequest = request
250233
if resumeSize > 0 {
251234
newRequest.setValue("bytes=\(resumeSize)-", forHTTPHeaderField: "Range")
252-
print("[Downloader] Adding Range header: bytes=\(resumeSize)-")
253235
}
254236

255237
// Start the download and get the byte stream
256238
let (asyncBytes, response) = try await session.bytes(for: newRequest)
257239

258240
guard let httpResponse = response as? HTTPURLResponse else {
259-
print("[Downloader] Error: Non-HTTP response received")
260241
throw DownloadError.unexpectedError
261242
}
262-
263-
print("[Downloader] Received HTTP \(httpResponse.statusCode) response")
264-
if let contentRange = httpResponse.value(forHTTPHeaderField: "Content-Range") {
265-
print("[Downloader] Content-Range: \(contentRange)")
266-
}
267-
if let contentLength = httpResponse.value(forHTTPHeaderField: "Content-Length") {
268-
print("[Downloader] Content-Length: \(contentLength)")
269-
}
270-
271243
guard (200..<300).contains(httpResponse.statusCode) else {
272-
print("[Downloader] Error: HTTP status code \(httpResponse.statusCode)")
273244
throw DownloadError.unexpectedError
274245
}
275246

@@ -323,10 +294,7 @@ class Downloader: NSObject, ObservableObject {
323294
// Verify the downloaded file size matches the expected size
324295
let actualSize = try tempFile.seekToEnd()
325296
if let expectedSize, expectedSize != actualSize {
326-
print("[Downloader] Error: Size mismatch - expected \(expectedSize) bytes but got \(actualSize) bytes")
327297
throw DownloadError.unexpectedError
328-
} else {
329-
print("[Downloader] Final verification passed, size: \(actualSize) bytes")
330298
}
331299
}
332300

Sources/Hub/HubApi.swift

-4
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,7 @@ public extension HubApi {
433433
if FileManager.default.fileExists(atPath: incompleteFile.path) {
434434
if let fileAttributes = try? FileManager.default.attributesOfItem(atPath: incompleteFile.path) {
435435
resumeSize = (fileAttributes[FileAttributeKey.size] as? Int) ?? 0
436-
print("[HubApi] Found existing incomplete file for \(destination.lastPathComponent): \(resumeSize) bytes at \(incompleteFile.path)")
437436
}
438-
} else {
439-
print("[HubApi] No existing incomplete file found for \(destination.lastPathComponent)")
440437
}
441438

442439
let downloader = Downloader(
@@ -466,7 +463,6 @@ public extension HubApi {
466463
return destination
467464
} catch {
468465
// If download fails, leave the incomplete file in place for future resume
469-
print("[HubApi] Download failed but incomplete file is preserved for future resume: \(error.localizedDescription)")
470466
throw error
471467
}
472468

0 commit comments

Comments
 (0)