Skip to content

Commit

Permalink
Version 6.1.8 (#3228)
Browse files Browse the repository at this point in the history
  • Loading branch information
marinofaggiana authored Dec 6, 2024
1 parent 566dad5 commit fda9328
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 44 deletions.
24 changes: 11 additions & 13 deletions File Provider Extension/FileProviderExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,17 @@ class FileProviderExtension: NSFileProviderExtension {
selector: "",
status: NCGlobal.shared.metadataStatusUploading)

DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
if let task = NKBackground(nkCommonInstance: NextcloudKit.shared.nkCommonInstance).upload(serverUrlFileName: serverUrlFileName,
fileNameLocalPath: url.path,
dateCreationFile: nil,
dateModificationFile: nil,
overwrite: true,
account: metadata.account,
sessionIdentifier: metadata.session) {
self.database.setMetadataSession(ocId: metadata.ocId,
sessionTaskIdentifier: task.taskIdentifier,
status: NCGlobal.shared.metadataStatusUploading)
fileProviderData.shared.fileProviderManager.register(task, forItemWithIdentifier: NSFileProviderItemIdentifier(metadata.fileId)) { _ in }
}
if let task = NKBackground(nkCommonInstance: NextcloudKit.shared.nkCommonInstance).upload(serverUrlFileName: serverUrlFileName,
fileNameLocalPath: url.path,
dateCreationFile: nil,
dateModificationFile: nil,
overwrite: true,
account: metadata.account,
sessionIdentifier: NCNetworking.shared.sessionUploadBackgroundExt) {
self.database.setMetadataSession(ocId: metadata.ocId,
sessionTaskIdentifier: task.taskIdentifier,
status: NCGlobal.shared.metadataStatusUploading)
fileProviderData.shared.fileProviderManager.register(task, forItemWithIdentifier: NSFileProviderItemIdentifier(metadata.fileId)) { _ in }
}
}

Expand Down
8 changes: 4 additions & 4 deletions Nextcloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5487,7 +5487,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 11;
CURRENT_PROJECT_VERSION = 2;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = NKUJUXUJ3B;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -5514,7 +5514,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.1.7;
MARKETING_VERSION = 6.1.8;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-v";
OTHER_LDFLAGS = "";
Expand Down Expand Up @@ -5553,7 +5553,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 11;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = NKUJUXUJ3B;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand All @@ -5577,7 +5577,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.1.7;
MARKETING_VERSION = 6.1.8;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-v";
OTHER_LDFLAGS = "";
Expand Down
12 changes: 12 additions & 0 deletions iOSClient/Data/NCManageDatabase+Metadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,18 @@ extension NCManageDatabase {
}
}

func deleteMetadataOcIds(_ ocIds: [String]) {
do {
let realm = try Realm()
try realm.write {
let results = realm.objects(tableMetadata.self).filter("ocId IN %@", ocIds)
realm.delete(results)
}
} catch let error as NSError {
NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] Could not access database: \(error)")
}
}

func deleteMetadatas(_ metadatas: [tableMetadata]) {
do {
let realm = try Realm()
Expand Down
50 changes: 27 additions & 23 deletions iOSClient/Media/NCMedia.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class NCMedia: UIViewController {
@IBOutlet weak var menuButton: UIButton!
@IBOutlet weak var gradientView: UIView!

let semaphore = DispatchSemaphore(value: 1)
var hasRunSearchMedia: Bool = false
let semaphoreSearchMedia = DispatchSemaphore(value: 1)
let semaphoreNotificationCenter = DispatchSemaphore(value: 1)

let layout = NCMediaLayout()
var layoutType = NCGlobal.shared.mediaLayoutRatio
Expand All @@ -54,6 +54,8 @@ class NCMedia: UIViewController {
var isEditMode = false
var fileSelect: [String] = []
var filesExists: [String] = []
var ocIdDoNotExists: [String] = []
var hasRunSearchMedia: Bool = false
var attributesZoomIn: UIMenuElement.Attributes = []
var attributesZoomOut: UIMenuElement.Attributes = []
let gradient: CAGradientLayer = CAGradientLayer()
Expand Down Expand Up @@ -255,12 +257,21 @@ class NCMedia: UIViewController {
guard let userInfo = notification.userInfo as NSDictionary?,
let error = userInfo["error"] as? NKError else { return }

if error.errorCode == self.global.errorResourceNotFound, let ocId = userInfo["ocId"] as? String {
semaphoreNotificationCenter.wait()

if error.errorCode == self.global.errorResourceNotFound,
let ocId = userInfo["ocId"] as? String {
self.database.deleteMetadataOcId(ocId)
self.loadDataSource()
self.loadDataSource {
self.semaphoreNotificationCenter.signal()
}
} else if error != .success {
NCContentPresenter().showError(error: error)
self.loadDataSource()
self.loadDataSource {
self.semaphoreNotificationCenter.signal()
}
} else {
semaphoreNotificationCenter.signal()
}
}

Expand All @@ -271,28 +282,21 @@ class NCMedia: UIViewController {
@objc func fileExists(_ notification: NSNotification) {
guard let userInfo = notification.userInfo as NSDictionary?,
let ocId = userInfo["ocId"] as? String,
let fileExists = userInfo["fileExists"] as? Bool else { return }
var indexPaths: [IndexPath] = []
let fileExists = userInfo["fileExists"] as? Bool
else {
return
}

filesExists.append(ocId)

if !fileExists {
if let index = dataSource.metadatas.firstIndex(where: {$0.ocId == ocId}),
index < self.dataSource.metadatas.count,
let cell = collectionView.cellForItem(at: IndexPath(row: index, section: 0)) as? NCMediaCell,
dataSource.metadatas[index].ocId == cell.ocId {
indexPaths.append(IndexPath(row: index, section: 0))
}

dataSource.removeMetadata([ocId])
database.deleteMetadataOcId(ocId)
ocIdDoNotExists.append(ocId)
}

if !indexPaths.isEmpty,
!indexPaths.filter({ $0.item < self.dataSource.metadatas.count }).isEmpty {
collectionView.deleteItems(at: indexPaths)
} else {
collectionViewReloadData()
}
if NCNetworking.shared.fileExistsQueue.operationCount == 0, !ocIdDoNotExists.isEmpty {
dataSource.removeMetadata(ocIdDoNotExists)
database.deleteMetadataOcIds(ocIdDoNotExists)
ocIdDoNotExists.removeAll()
collectionViewReloadData()
}
}

Expand Down
7 changes: 4 additions & 3 deletions iOSClient/Media/NCMediaDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ import NextcloudKit
import RealmSwift

extension NCMedia {
func loadDataSource() {
func loadDataSource(completion: @escaping () -> Void = {}) {
let session = self.session
DispatchQueue.global().async {
if let metadatas = self.database.getResultsMetadatas(predicate: self.imageCache.getMediaPredicate(filterLivePhotoFile: true, session: session, showOnlyImages: self.showOnlyImages, showOnlyVideos: self.showOnlyVideos), sortedByKeyPath: "date") {
self.dataSource = NCMediaDataSource(metadatas: metadatas)
}
self.collectionViewReloadData()
completion()
}
}

Expand Down Expand Up @@ -61,7 +62,7 @@ extension NCMedia {
let visibleCells = self.collectionView?.indexPathsForVisibleItems.sorted(by: { $0.row < $1.row }).compactMap({ self.collectionView?.cellForItem(at: $0) })

DispatchQueue.global(qos: .background).async {
self.semaphore.wait()
self.semaphoreSearchMedia.wait()
self.hasRunSearchMedia = true

var lessDate = Date.distantFuture
Expand Down Expand Up @@ -156,7 +157,7 @@ extension NCMedia {
self.collectionViewReloadData()
}

self.semaphore.signal()
self.semaphoreSearchMedia.signal()

DispatchQueue.main.async {
self.activityIndicator.stopAnimating()
Expand Down
3 changes: 2 additions & 1 deletion iOSClient/Networking/NCNetworking+WebDAV.swift
Original file line number Diff line number Diff line change
Expand Up @@ -841,12 +841,13 @@ class NCOperationFileExists: ConcurrentOperation, @unchecked Sendable {
requestBody: nil,
account: account,
options: options) { _, _, _, error in
self.finish()

if error == .success {
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterFileExists, userInfo: ["ocId": self.ocId, "fileExists": true])
} else if error.errorCode == NCGlobal.shared.errorResourceNotFound {
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterFileExists, userInfo: ["ocId": self.ocId, "fileExists": false])
}
self.finish()
}
}
}
Expand Down
Binary file modified iOSClient/Supporting Files/de.lproj/Localizable.strings
Binary file not shown.
Binary file modified iOSClient/Supporting Files/eu.lproj/Localizable.strings
Binary file not shown.
Binary file modified iOSClient/Supporting Files/ga.lproj/Localizable.strings
Binary file not shown.
Binary file modified iOSClient/Supporting Files/ja-JP.lproj/Localizable.strings
Binary file not shown.
Binary file modified iOSClient/Supporting Files/ko.lproj/Localizable.strings
Binary file not shown.
Binary file modified iOSClient/Supporting Files/pt-BR.lproj/Localizable.strings
Binary file not shown.

0 comments on commit fda9328

Please sign in to comment.