Skip to content

Commit

Permalink
refactor(PHAssetIdentifier): Cleaned some dead code that allowed me t…
Browse files Browse the repository at this point in the history
…o make an init non nullable
  • Loading branch information
adrien-coye committed Jan 31, 2025
1 parent 42a5768 commit 1a4dae5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
10 changes: 2 additions & 8 deletions kDriveCore/Utils/PHAsset/PHAsset+Exension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ public extension PHAsset {
/// Will return `nil` for any other resource type (like video)
var baseImageSHA256: String? {
get throws {
guard let identifier = PHAssetIdentifier(self) else {
return nil
}

let identifier = PHAssetIdentifier(self)
let hash = try identifier.baseImageSHA256
return hash
}
Expand All @@ -41,10 +38,7 @@ public extension PHAsset {
/// Hash of the best resource available. Editing a video or a picture will change this hash
var bestResourceSHA256: String? {
get throws {
guard let identifier = PHAssetIdentifier(self) else {
return nil
}

let identifier = PHAssetIdentifier(self)
let hash = try identifier.bestResourceSHA256
return hash
}
Expand Down
14 changes: 1 addition & 13 deletions kDriveCore/Utils/PHAsset/PHAssetIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,12 @@ final class AssetExpiringActivityDelegate: ExpiringActivityDelegate {
struct PHAssetIdentifier: PHAssetIdentifiable {
let asset: PHAsset

init?(_ asset: PHAsset) {
guard #available(iOS 15, *) else {
return nil
}

init(_ asset: PHAsset) {
self.asset = asset
}

var baseImageSHA256: String? {
get throws {
guard #available(iOS 15, *) else {
return nil
}

// We build an ExpiringActivity to track system termination
let uid = "\(#function)-\(asset.localIdentifier)-\(UUID().uuidString)"
let group = TolerantDispatchGroup()
Expand Down Expand Up @@ -129,10 +121,6 @@ struct PHAssetIdentifier: PHAssetIdentifiable {

var bestResourceSHA256: String? {
get throws {
guard #available(iOS 15, *) else {
return nil
}

guard let bestResource = asset.bestResource else {
let hashFallback = try baseImageSHA256
return hashFallback
Expand Down

0 comments on commit 1a4dae5

Please sign in to comment.