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
I recently tried to write a Cloud Document manager in Files, and I found that in a particular case, the loadModificationDate method might crash my application. My guess is that Cloud is downloading or synchronizing files.
I tried to find the reason, and finally found that try! fileManager.attributesOfItem(atPath: path) is likely to make a mistake, because at this time it may not be able to get any attributes at all. Or return attributes[FileAttributeKey.modificationDate] as! Date is wrong because it may not have this attribute.
So I think Files, the way to read file attributes, should be nil. This makes Files more rigorous..
Just like this:
func loadModificationDate() -> Date? {
let attributes = try? fileManager.attributesOfItem(atPath: path)
return attributes?[FileAttributeKey.modificationDate] as? Date
}
The text was updated successfully, but these errors were encountered:
Hello, yes, my English is still so bad.
I recently tried to write a Cloud Document manager in Files, and I found that in a particular case, the loadModificationDate method might crash my application. My guess is that Cloud is downloading or synchronizing files.
I tried to find the reason, and finally found that try! fileManager.attributesOfItem(atPath: path) is likely to make a mistake, because at this time it may not be able to get any attributes at all. Or return attributes[FileAttributeKey.modificationDate] as! Date is wrong because it may not have this attribute.
So I think Files, the way to read file attributes, should be nil. This makes Files more rigorous..
Just like this:
The text was updated successfully, but these errors were encountered: