Hi, I encounter unexpected behavior from the FileWrapper updates that occurs when I remove file using FileManager.removeItem
If I first remove a file from the directory, then create NSFileWrapper instance, I get unexpected values from calls to matchesContents(of:)
import Foundation
let copyURL = URL(filePath: "/Users/marcinkrzyzanowski/Downloads/filewrappertest.test/COPY.png")
// THIS OPERATION BREAKS IT. REMOVE IT TO WORK AS EXPECTED
try! FileManager().removeItem(at: copyURL)
let dirURL = URL(filePath: "/Users/marcinkrzyzanowski/Downloads/filewrappertest.test")
let fw = try FileWrapper(url: dirURL)
fw.fileWrappers // ["IMG_0736.png"]
try FileManager.default.copyItem(at: URL(filePath: "/Users/marcinkrzyzanowski/Downloads/filewrappertest.test/IMG_0736.png"), to: copyURL)
fw.fileWrappers // ["IMG_0736.png"]
fw.matchesContents(of: dirURL) // true (expected: false)
try fw.read(from: dirURL)
fw.fileWrappers! // ["COPY.png", "IMG_0736.png"]
fw.matchesContents(of: dirURL) // true
I don't understand why the "FileManager.removeItem" affects the NSFileWrapper behavior in such a way. It does not change even when I add a delay after removeItem
. Any idea?