File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -157,21 +157,21 @@ public extension HubApi {
157
157
@discardableResult
158
158
func download( progressHandler: @escaping ( Double ) -> Void ) async throws -> URL {
159
159
guard !downloaded else { return destination }
160
-
160
+
161
161
try prepareDestination ( )
162
162
let downloader = Downloader ( from: source, to: destination, using: hfToken)
163
163
let downloadSubscriber = downloader. downloadState. sink { state in
164
164
if case . downloading( let progress) = state {
165
165
progressHandler ( progress)
166
166
}
167
167
}
168
- // We need to assign the cancellable to a var so we keep receiving events, so we suppress the "unused var" warning here
169
- let _ = downloadSubscriber
170
- try downloader . waitUntilDone ( )
168
+ _ = try withExtendedLifetime ( downloadSubscriber ) {
169
+ try downloader . waitUntilDone ( )
170
+ }
171
171
return destination
172
172
}
173
173
}
174
-
174
+
175
175
@discardableResult
176
176
func snapshot( from repo: Repo , matching globs: [ String ] = [ ] , progressHandler: @escaping ( Progress ) -> Void = { _ in } ) async throws -> URL {
177
177
let filenames = try await getFilenames ( from: repo, matching: globs)
You can’t perform that action at this time.
0 commit comments