Skip to content

Commit fda9328

Browse files
Version 6.1.8 (#3228)
1 parent 566dad5 commit fda9328

File tree

12 files changed

+60
-44
lines changed

12 files changed

+60
-44
lines changed

β€ŽFile Provider Extension/FileProviderExtension.swiftβ€Ž

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -254,19 +254,17 @@ class FileProviderExtension: NSFileProviderExtension {
254254
selector: "",
255255
status: NCGlobal.shared.metadataStatusUploading)
256256

257-
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
258-
if let task = NKBackground(nkCommonInstance: NextcloudKit.shared.nkCommonInstance).upload(serverUrlFileName: serverUrlFileName,
259-
fileNameLocalPath: url.path,
260-
dateCreationFile: nil,
261-
dateModificationFile: nil,
262-
overwrite: true,
263-
account: metadata.account,
264-
sessionIdentifier: metadata.session) {
265-
self.database.setMetadataSession(ocId: metadata.ocId,
266-
sessionTaskIdentifier: task.taskIdentifier,
267-
status: NCGlobal.shared.metadataStatusUploading)
268-
fileProviderData.shared.fileProviderManager.register(task, forItemWithIdentifier: NSFileProviderItemIdentifier(metadata.fileId)) { _ in }
269-
}
257+
if let task = NKBackground(nkCommonInstance: NextcloudKit.shared.nkCommonInstance).upload(serverUrlFileName: serverUrlFileName,
258+
fileNameLocalPath: url.path,
259+
dateCreationFile: nil,
260+
dateModificationFile: nil,
261+
overwrite: true,
262+
account: metadata.account,
263+
sessionIdentifier: NCNetworking.shared.sessionUploadBackgroundExt) {
264+
self.database.setMetadataSession(ocId: metadata.ocId,
265+
sessionTaskIdentifier: task.taskIdentifier,
266+
status: NCGlobal.shared.metadataStatusUploading)
267+
fileProviderData.shared.fileProviderManager.register(task, forItemWithIdentifier: NSFileProviderItemIdentifier(metadata.fileId)) { _ in }
270268
}
271269
}
272270

β€ŽNextcloud.xcodeproj/project.pbxprojβ€Ž

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5487,7 +5487,7 @@
54875487
CLANG_WARN_UNREACHABLE_CODE = YES;
54885488
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
54895489
COPY_PHASE_STRIP = NO;
5490-
CURRENT_PROJECT_VERSION = 11;
5490+
CURRENT_PROJECT_VERSION = 2;
54915491
DEBUG_INFORMATION_FORMAT = dwarf;
54925492
DEVELOPMENT_TEAM = NKUJUXUJ3B;
54935493
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -5514,7 +5514,7 @@
55145514
"@executable_path/Frameworks",
55155515
"@executable_path/../../Frameworks",
55165516
);
5517-
MARKETING_VERSION = 6.1.7;
5517+
MARKETING_VERSION = 6.1.8;
55185518
ONLY_ACTIVE_ARCH = YES;
55195519
OTHER_CFLAGS = "-v";
55205520
OTHER_LDFLAGS = "";
@@ -5553,7 +5553,7 @@
55535553
CLANG_WARN_UNREACHABLE_CODE = YES;
55545554
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
55555555
COPY_PHASE_STRIP = NO;
5556-
CURRENT_PROJECT_VERSION = 11;
5556+
CURRENT_PROJECT_VERSION = 2;
55575557
DEVELOPMENT_TEAM = NKUJUXUJ3B;
55585558
ENABLE_STRICT_OBJC_MSGSEND = YES;
55595559
ENABLE_TESTABILITY = YES;
@@ -5577,7 +5577,7 @@
55775577
"@executable_path/Frameworks",
55785578
"@executable_path/../../Frameworks",
55795579
);
5580-
MARKETING_VERSION = 6.1.7;
5580+
MARKETING_VERSION = 6.1.8;
55815581
ONLY_ACTIVE_ARCH = YES;
55825582
OTHER_CFLAGS = "-v";
55835583
OTHER_LDFLAGS = "";

β€ŽiOSClient/Data/NCManageDatabase+Metadata.swiftβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,18 @@ extension NCManageDatabase {
615615
}
616616
}
617617

618+
func deleteMetadataOcIds(_ ocIds: [String]) {
619+
do {
620+
let realm = try Realm()
621+
try realm.write {
622+
let results = realm.objects(tableMetadata.self).filter("ocId IN %@", ocIds)
623+
realm.delete(results)
624+
}
625+
} catch let error as NSError {
626+
NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] Could not access database: \(error)")
627+
}
628+
}
629+
618630
func deleteMetadatas(_ metadatas: [tableMetadata]) {
619631
do {
620632
let realm = try Realm()

β€ŽiOSClient/Media/NCMedia.swiftβ€Ž

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class NCMedia: UIViewController {
3636
@IBOutlet weak var menuButton: UIButton!
3737
@IBOutlet weak var gradientView: UIView!
3838

39-
let semaphore = DispatchSemaphore(value: 1)
40-
var hasRunSearchMedia: Bool = false
39+
let semaphoreSearchMedia = DispatchSemaphore(value: 1)
40+
let semaphoreNotificationCenter = DispatchSemaphore(value: 1)
4141

4242
let layout = NCMediaLayout()
4343
var layoutType = NCGlobal.shared.mediaLayoutRatio
@@ -54,6 +54,8 @@ class NCMedia: UIViewController {
5454
var isEditMode = false
5555
var fileSelect: [String] = []
5656
var filesExists: [String] = []
57+
var ocIdDoNotExists: [String] = []
58+
var hasRunSearchMedia: Bool = false
5759
var attributesZoomIn: UIMenuElement.Attributes = []
5860
var attributesZoomOut: UIMenuElement.Attributes = []
5961
let gradient: CAGradientLayer = CAGradientLayer()
@@ -255,12 +257,21 @@ class NCMedia: UIViewController {
255257
guard let userInfo = notification.userInfo as NSDictionary?,
256258
let error = userInfo["error"] as? NKError else { return }
257259

258-
if error.errorCode == self.global.errorResourceNotFound, let ocId = userInfo["ocId"] as? String {
260+
semaphoreNotificationCenter.wait()
261+
262+
if error.errorCode == self.global.errorResourceNotFound,
263+
let ocId = userInfo["ocId"] as? String {
259264
self.database.deleteMetadataOcId(ocId)
260-
self.loadDataSource()
265+
self.loadDataSource {
266+
self.semaphoreNotificationCenter.signal()
267+
}
261268
} else if error != .success {
262269
NCContentPresenter().showError(error: error)
263-
self.loadDataSource()
270+
self.loadDataSource {
271+
self.semaphoreNotificationCenter.signal()
272+
}
273+
} else {
274+
semaphoreNotificationCenter.signal()
264275
}
265276
}
266277

@@ -271,28 +282,21 @@ class NCMedia: UIViewController {
271282
@objc func fileExists(_ notification: NSNotification) {
272283
guard let userInfo = notification.userInfo as NSDictionary?,
273284
let ocId = userInfo["ocId"] as? String,
274-
let fileExists = userInfo["fileExists"] as? Bool else { return }
275-
var indexPaths: [IndexPath] = []
285+
let fileExists = userInfo["fileExists"] as? Bool
286+
else {
287+
return
288+
}
276289

277290
filesExists.append(ocId)
278-
279291
if !fileExists {
280-
if let index = dataSource.metadatas.firstIndex(where: {$0.ocId == ocId}),
281-
index < self.dataSource.metadatas.count,
282-
let cell = collectionView.cellForItem(at: IndexPath(row: index, section: 0)) as? NCMediaCell,
283-
dataSource.metadatas[index].ocId == cell.ocId {
284-
indexPaths.append(IndexPath(row: index, section: 0))
285-
}
286-
287-
dataSource.removeMetadata([ocId])
288-
database.deleteMetadataOcId(ocId)
292+
ocIdDoNotExists.append(ocId)
293+
}
289294

290-
if !indexPaths.isEmpty,
291-
!indexPaths.filter({ $0.item < self.dataSource.metadatas.count }).isEmpty {
292-
collectionView.deleteItems(at: indexPaths)
293-
} else {
294-
collectionViewReloadData()
295-
}
295+
if NCNetworking.shared.fileExistsQueue.operationCount == 0, !ocIdDoNotExists.isEmpty {
296+
dataSource.removeMetadata(ocIdDoNotExists)
297+
database.deleteMetadataOcIds(ocIdDoNotExists)
298+
ocIdDoNotExists.removeAll()
299+
collectionViewReloadData()
296300
}
297301
}
298302

β€ŽiOSClient/Media/NCMediaDataSource.swiftβ€Ž

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ import NextcloudKit
2626
import RealmSwift
2727

2828
extension NCMedia {
29-
func loadDataSource() {
29+
func loadDataSource(completion: @escaping () -> Void = {}) {
3030
let session = self.session
3131
DispatchQueue.global().async {
3232
if let metadatas = self.database.getResultsMetadatas(predicate: self.imageCache.getMediaPredicate(filterLivePhotoFile: true, session: session, showOnlyImages: self.showOnlyImages, showOnlyVideos: self.showOnlyVideos), sortedByKeyPath: "date") {
3333
self.dataSource = NCMediaDataSource(metadatas: metadatas)
3434
}
3535
self.collectionViewReloadData()
36+
completion()
3637
}
3738
}
3839

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

6364
DispatchQueue.global(qos: .background).async {
64-
self.semaphore.wait()
65+
self.semaphoreSearchMedia.wait()
6566
self.hasRunSearchMedia = true
6667

6768
var lessDate = Date.distantFuture
@@ -156,7 +157,7 @@ extension NCMedia {
156157
self.collectionViewReloadData()
157158
}
158159

159-
self.semaphore.signal()
160+
self.semaphoreSearchMedia.signal()
160161

161162
DispatchQueue.main.async {
162163
self.activityIndicator.stopAnimating()

β€ŽiOSClient/Networking/NCNetworking+WebDAV.swiftβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,12 +841,13 @@ class NCOperationFileExists: ConcurrentOperation, @unchecked Sendable {
841841
requestBody: nil,
842842
account: account,
843843
options: options) { _, _, _, error in
844+
self.finish()
845+
844846
if error == .success {
845847
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterFileExists, userInfo: ["ocId": self.ocId, "fileExists": true])
846848
} else if error.errorCode == NCGlobal.shared.errorResourceNotFound {
847849
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterFileExists, userInfo: ["ocId": self.ocId, "fileExists": false])
848850
}
849-
self.finish()
850851
}
851852
}
852853
}
76 Bytes
Binary file not shown.
58 Bytes
Binary file not shown.
48 Bytes
Binary file not shown.
-604 Bytes
Binary file not shown.

0 commit comments

Comments
Β (0)