You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After all, I rebuilt it using FileManager class...
It's not only can work async, but also 5 times faster
let url = PARRENT_DIR
let disk = FileManager.default
let queue = OperationQueue()
queue.addOperation {
guard let files = try? disk.subpathsOfDirectory(atPath: url.path) else {return}
let list = files
.filter({.....})
.map({ url.appendingPathComponent($0).path })
}
queue.waitUntilAllOperationsAreFinished()
print(list.count)
Hi I have next code:
as you may see - it scans all subfolders for subfolders with specific extension excluding specific filename, and put their parent folders in a list.
But when I put it in a DispatchQueue.global().async {} block (as shown above) - it stops at
line in method
func pathByFillingInParentReferences(for path: String, prependCurrentFolderPath: Bool = false) throws -> String {
with error: Thread 2: EXC_BAD_ACCESS (code=2, address=0x70000bf20ff0)
In a stack I see over 1000 calls of
FileSystemIterator.next()
, so I think it's a recursion.What I did wrong and how to fix it?
The text was updated successfully, but these errors were encountered: