Skip to content

Commit

Permalink
Merge pull request #1185 from Infomaniak/fixPredicateCrash
Browse files Browse the repository at this point in the history
fix: Search offline works when filtering by file type.
  • Loading branch information
adrien-coye authored May 21, 2024
2 parents f36a623 + f7fc20d commit 44de97a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kDriveCore/Data/Cache/DriveFileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -680,20 +680,23 @@ public final class DriveFileManager {
if let query, !query.isBlank {
searchResults = searchResults.filter(NSPredicate(format: "name CONTAINS[cd] %@", query))
}

if let date {
searchResults = searchResults.filter(NSPredicate(
format: "lastModifiedAt >= %d && lastModifiedAt <= %d",
Int(date.start.timeIntervalSince1970),
Int(date.end.timeIntervalSince1970)
))
}

if let fileType {
if fileType == .folder {
searchResults = searchResults.filter(NSPredicate(format: "rawType == \"dir\""))
} else {
searchResults = searchResults.filter(NSPredicate(format: "rawConvertedType == %@", fileType.rawValue))
searchResults = searchResults.filter(NSPredicate(format: "extensionType == %@", fileType.rawValue))
}
}

if !categories.isEmpty {
let predicate: NSPredicate
if belongToAllCategories {
Expand Down

0 comments on commit 44de97a

Please sign in to comment.