This commit is contained in:
fmodf 2024-07-13 18:29:08 +02:00
parent 36bfdf9dcb
commit 318d792928
3 changed files with 7 additions and 3 deletions

View file

@ -27,10 +27,14 @@ final class DownloadManager {
if let tempLocalUrl = tempLocalUrl, error == nil {
do {
let destinationDirectory = localUrl.deletingLastPathComponent()
if !FileManager.default.fileExists(atPath: destinationDirectory.path) {
try FileManager.default.createDirectory(at: destinationDirectory, withIntermediateDirectories: true, attributes: nil)
}
if FileManager.default.fileExists(atPath: localUrl.path) {
try FileManager.default.removeItem(at: localUrl)
}
try FileManager.default.copyItem(at: tempLocalUrl, to: localUrl)
try FileManager.default.moveItem(at: tempLocalUrl, to: localUrl)
completion(nil)
} catch let writeError {
completion(writeError)

View file

@ -298,7 +298,7 @@ final class DatabaseMiddleware {
_ = try database._db.write { db in
try Message
.filter(Column("id") == id)
.updateAll(db, Column("attachmentLocalPath").set(to: localUrl))
.updateAll(db, Column("attachmentLocalPath").set(to: localUrl), Column("attachmentDownloadFailed").set(to: false))
}
promise(.success(.empty))
} catch {

View file

@ -33,7 +33,7 @@ enum Const {
static let videoDurationLimit = 60.0
// Upload/download file folder
static let fileFolder = "Downloads"
static let fileFolder = "downloads"
// Grid size for gallery preview (3 in a row)
static let galleryGridSize = UIScreen.main.bounds.width / 3