Add isFileSynced helper func to FileProviderFilesUtils

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-01-12 20:34:07 +01:00
parent 5f9f0311d1
commit 9ff66bb94f
No known key found for this signature in database
GPG key ID: C839200C384636B0

View file

@ -102,3 +102,17 @@ func parentItemIdentifierFromMetadata(_ metadata: NextcloudFileMetadataTable) ->
return nil
}
func isFileSynced(metadata: NextcloudFileMetadataTable) -> Bool {
do {
let localPathForFile = try localPathForNCFile(fileMetadata: metadata)
let localFileAttributes = try FileManager.default.attributesOfItem(atPath: localPathForFile.path)
let localFileSize = localFileAttributes[.size] as? Int64
return localFileSize == metadata.size
} catch let error {
print("Could not check if file %@ is synced, received error: %@", metadata.fileNameView, error)
}
return false
}