mirror of
				https://github.com/GayPizzaSpecifications/darwin-apk.git
				synced 2025-11-04 07:59:38 +00:00 
			
		
		
		
	first async refactor of fetch/index
This commit is contained in:
		@ -41,10 +41,10 @@ struct DpkSearchCommand: AsyncParsableCommand {
 | 
			
		||||
    let match: any PatternMatcher
 | 
			
		||||
    match = try matcher.init(patterns: patterns, ignoreCase: !self.caseSensitive)
 | 
			
		||||
 | 
			
		||||
    let localRepositories = try await RepositoriesConfig().localRepositories
 | 
			
		||||
    let localRepositories = try await ApkRepositoriesConfig()
 | 
			
		||||
    let index: ApkIndex
 | 
			
		||||
    do {
 | 
			
		||||
      index = ApkIndex.merge(try localRepositories.map(ApkIndex.init))
 | 
			
		||||
      index = try await ApkIndex.resolve(localRepositories, fetch: .local)
 | 
			
		||||
    } catch {
 | 
			
		||||
      print("Failed to build package index: \(error.localizedDescription)")
 | 
			
		||||
      throw .failure
 | 
			
		||||
 | 
			
		||||
@ -13,11 +13,13 @@ struct DpkUpdateCommand: AsyncParsableCommand {
 | 
			
		||||
    abstract: "Update the system package repositories.",
 | 
			
		||||
    aliases: [ "u" ])
 | 
			
		||||
 | 
			
		||||
  @Flag(help: "Index on-disk cache")
 | 
			
		||||
  var lazyDownload: Bool = false
 | 
			
		||||
 | 
			
		||||
  func run() async throws {
 | 
			
		||||
    let repositories = try await ApkRepositoriesConfig().repositories
 | 
			
		||||
    print("Updating package repositories")
 | 
			
		||||
    let repositories = try await RepositoriesConfig().repositories
 | 
			
		||||
    var updater = ApkIndexUpdater()
 | 
			
		||||
    updater.repositories.append(contentsOf: repositories)
 | 
			
		||||
    updater.update()
 | 
			
		||||
    let index = try await ApkIndex.resolve(repositories, fetch: self.lazyDownload ? .lazy : .update)
 | 
			
		||||
    print("Indexed \(index.packages.count) package(s)")
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user