Skip to content

Commit 0933747

Browse files
Processing task Media (#4169)
* tableMediaMetadataBackfill Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * wip Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * wip Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * wip Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * wip Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * wip Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * wip Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * wip Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * wip * Stops the backfill when the media archive has already been fully processed Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * Retrieves and stores complete metadata when the media record is a placeholder. Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * runMediaMetadataPlaceholderHydration Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * wip Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * wip Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * wip * Update AppDelegate+AppProcessing.swift * Update AppDelegate+AppProcessing.swift * Update NCSettingsView.swift * wip * Update AppDelegate+AppProcessing.swift * limit Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * code Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * wip Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * wip Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * wip Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * cleaning Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * cleaning Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> * fix log Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com> --------- Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
1 parent 9304f1b commit 0933747

18 files changed

Lines changed: 564 additions & 92 deletions

Brand/Database.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ import Foundation
88
//
99
let databaseName = "nextcloud.realm"
1010
let tableAccountBackup = "tableAccountBackup.json"
11-
let databaseSchemaVersion: UInt64 = 411
11+
let databaseSchemaVersion: UInt64 = 412

Nextcloud.xcodeproj/project.pbxproj

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@
260260
F71916142E2901FB00E13E96 /* NCNetworking+Upload.swift in Sources */ = {isa = PBXBuildFile; fileRef = F71916102E2901E800E13E96 /* NCNetworking+Upload.swift */; };
261261
F719D9E0288D37A300762E33 /* NCColorPicker.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F719D9DF288D37A300762E33 /* NCColorPicker.storyboard */; };
262262
F719D9E2288D396100762E33 /* NCColorPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = F719D9E1288D396100762E33 /* NCColorPicker.swift */; };
263-
F71CFA672F2A07DB007A3AE9 /* NCMedia+Netwoking.swift in Sources */ = {isa = PBXBuildFile; fileRef = F71CFA662F2A07C6007A3AE9 /* NCMedia+Netwoking.swift */; };
263+
F71CFA672F2A07DB007A3AE9 /* NCMediaNetwork.swift in Sources */ = {isa = PBXBuildFile; fileRef = F71CFA662F2A07C6007A3AE9 /* NCMediaNetwork.swift */; };
264264
F71D2FB72E09BBD700B751CC /* NCAutoUploadModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F71D2FB62E09BBD700B751CC /* NCAutoUploadModel.swift */; };
265265
F71DFA222F59FB9A003A93C5 /* View+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7E8A390295DC5E0006CB2D0 /* View+Extension.swift */; };
266266
F71F6D072B6A6A5E00F1EB15 /* ThreadSafeArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = F71F6D062B6A6A5E00F1EB15 /* ThreadSafeArray.swift */; };
@@ -510,6 +510,12 @@
510510
F763D29F2A249C4500A3C901 /* NCManageDatabase+Capabilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = F763D29C2A249C4500A3C901 /* NCManageDatabase+Capabilities.swift */; };
511511
F763D2A02A249C4500A3C901 /* NCManageDatabase+Capabilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = F763D29C2A249C4500A3C901 /* NCManageDatabase+Capabilities.swift */; };
512512
F763D2A32A249C4500A3C901 /* NCManageDatabase+Capabilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = F763D29C2A249C4500A3C901 /* NCManageDatabase+Capabilities.swift */; };
513+
F764C3E12FFB7DFA00029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift in Sources */ = {isa = PBXBuildFile; fileRef = F764C3E02FFB7DF800029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift */; };
514+
F764C3E22FFB7DFA00029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift in Sources */ = {isa = PBXBuildFile; fileRef = F764C3E02FFB7DF800029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift */; };
515+
F764C3E32FFB7DFA00029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift in Sources */ = {isa = PBXBuildFile; fileRef = F764C3E02FFB7DF800029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift */; };
516+
F764C3E42FFB7DFA00029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift in Sources */ = {isa = PBXBuildFile; fileRef = F764C3E02FFB7DF800029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift */; };
517+
F764C3E52FFB7DFA00029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift in Sources */ = {isa = PBXBuildFile; fileRef = F764C3E02FFB7DF800029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift */; };
518+
F764C3E72FFB846D00029FD5 /* NCMediaMetadataBackfill.swift in Sources */ = {isa = PBXBuildFile; fileRef = F764C3E62FFB846C00029FD5 /* NCMediaMetadataBackfill.swift */; };
513519
F765E9CD295C585800A09ED8 /* NCUploadScanDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = F765E9CC295C585800A09ED8 /* NCUploadScanDocument.swift */; };
514520
F765F73125237E3F00391DBE /* NCRecent.swift in Sources */ = {isa = PBXBuildFile; fileRef = F765F72F25237E3F00391DBE /* NCRecent.swift */; };
515521
F765F73225237E3F00391DBE /* NCRecent.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F765F73025237E3F00391DBE /* NCRecent.storyboard */; };
@@ -782,6 +788,7 @@
782788
F7C55CC92FB5CE74004A974F /* ActionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C55CC32FB5CE74004A974F /* ActionViewController.swift */; };
783789
F7C55CCA2FB5CE74004A974F /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F7C55CC42FB5CE74004A974F /* Images.xcassets */; };
784790
F7C55CCC2FB5CE74004A974F /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7C55CC72FB5CE74004A974F /* MainInterface.storyboard */; };
791+
F7C630712FFE206100257EEB /* NCMediaMetadataBackgroundProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C630702FFE206100257EEB /* NCMediaMetadataBackgroundProcessor.swift */; };
785792
F7C687E92D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */; };
786793
F7C687EA2D22BDE5004757BC /* NCManageDatabase+RecommendedFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */; };
787794
F7C687EB2D22BDE5004757BC /* NCManageDatabase+RecommendedFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */; };
@@ -1413,7 +1420,7 @@
14131420
F71916102E2901E800E13E96 /* NCNetworking+Upload.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCNetworking+Upload.swift"; sourceTree = "<group>"; };
14141421
F719D9DF288D37A300762E33 /* NCColorPicker.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCColorPicker.storyboard; sourceTree = "<group>"; };
14151422
F719D9E1288D396100762E33 /* NCColorPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCColorPicker.swift; sourceTree = "<group>"; };
1416-
F71CFA662F2A07C6007A3AE9 /* NCMedia+Netwoking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCMedia+Netwoking.swift"; sourceTree = "<group>"; };
1423+
F71CFA662F2A07C6007A3AE9 /* NCMediaNetwork.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMediaNetwork.swift; sourceTree = "<group>"; };
14171424
F71D2FB62E09BBD700B751CC /* NCAutoUploadModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCAutoUploadModel.swift; sourceTree = "<group>"; };
14181425
F71F6D062B6A6A5E00F1EB15 /* ThreadSafeArray.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadSafeArray.swift; sourceTree = "<group>"; };
14191426
F721C5092FB6F9AA00207DA9 /* NCCollectionViewCommon+TransitionSourceBlink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCCollectionViewCommon+TransitionSourceBlink.swift"; sourceTree = "<group>"; };
@@ -1528,6 +1535,8 @@
15281535
F7635D8C2FB1F81D007F658D /* NCVideoVLCPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCVideoVLCPresenter.swift; sourceTree = "<group>"; };
15291536
F7637D7F2FE28CBF00F4F90E /* NCContextMenuActions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCContextMenuActions.swift; sourceTree = "<group>"; };
15301537
F763D29C2A249C4500A3C901 /* NCManageDatabase+Capabilities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NCManageDatabase+Capabilities.swift"; sourceTree = "<group>"; };
1538+
F764C3E02FFB7DF800029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCManageDatabase+MediaMetadataBackfill.swift"; sourceTree = "<group>"; };
1539+
F764C3E62FFB846C00029FD5 /* NCMediaMetadataBackfill.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMediaMetadataBackfill.swift; sourceTree = "<group>"; };
15311540
F765E9CC295C585800A09ED8 /* NCUploadScanDocument.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCUploadScanDocument.swift; sourceTree = "<group>"; };
15321541
F765F72F25237E3F00391DBE /* NCRecent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCRecent.swift; sourceTree = "<group>"; };
15331542
F765F73025237E3F00391DBE /* NCRecent.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = NCRecent.storyboard; sourceTree = "<group>"; };
@@ -1798,6 +1807,7 @@
17981807
F7C55CC32FB5CE74004A974F /* ActionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionViewController.swift; sourceTree = "<group>"; };
17991808
F7C55CC42FB5CE74004A974F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
18001809
F7C55CC62FB5CE74004A974F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
1810+
F7C630702FFE206100257EEB /* NCMediaMetadataBackgroundProcessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCMediaMetadataBackgroundProcessor.swift; sourceTree = "<group>"; };
18011811
F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCManageDatabase+RecommendedFiles.swift"; sourceTree = "<group>"; };
18021812
F7C7B488245EBA4100D93E60 /* NCViewerQuickLook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerQuickLook.swift; sourceTree = "<group>"; };
18031813
F7C9555221F0C4CA0024296E /* NCActivity.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCActivity.storyboard; sourceTree = "<group>"; };
@@ -3084,6 +3094,7 @@
30843094
F73EF7B62B0224AB0087E6E9 /* NCManageDatabase+ExternalSites.swift */,
30853095
F73EF7BE2B02250B0087E6E9 /* NCManageDatabase+GPS.swift */,
30863096
F757CC8129E7F88B00F31428 /* NCManageDatabase+Groupfolders.swift */,
3097+
F764C3E02FFB7DF800029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift */,
30873098
F7BF9D812934CA21009EE9A6 /* NCManageDatabase+LayoutForView.swift */,
30883099
F77E8C1E2E79717D00EAE68F /* NCManageDatabase+LivePhoto.swift */,
30893100
F7864ACB2A78FE73004870E0 /* NCManageDatabase+LocalFile.swift */,
@@ -3390,11 +3401,12 @@
33903401
F72408322B8A27C900F128E2 /* NCMedia+Command.swift */,
33913402
F7802B312BD5584F00D74270 /* NCMedia+DragDrop.swift */,
33923403
F7BD0A032C4689E9003A4A6D /* NCMedia+MediaLayout.swift */,
3393-
F71CFA662F2A07C6007A3AE9 /* NCMedia+Netwoking.swift */,
33943404
F7E2B64E2DDCC5C30075B4D0 /* NCMedia+TransferDelegate.swift */,
33953405
F78B87E62B62527100C65ADC /* NCMediaDataSource.swift */,
33963406
F755CB3F2B8CB13C00CE27E9 /* NCMediaLayout.swift */,
3407+
F764C3E62FFB846C00029FD5 /* NCMediaMetadataBackfill.swift */,
33973408
F79699E62E689F68000EC82A /* NCMediaNavigationController.swift */,
3409+
F71CFA662F2A07C6007A3AE9 /* NCMediaNetwork.swift */,
33983410
F7D60CAE2C941ACB008FBFDD /* NCMediaPinchGesture.swift */,
33993411
F741C2232B6B9FD600E849BB /* NCMediaSelectTabBar.swift */,
34003412
);
@@ -3504,6 +3516,7 @@
35043516
F77DD6A72C5CC093009448FB /* NCSession.swift */,
35053517
F76B649B2ADFFAED00014640 /* NCImageCache.swift */,
35063518
F702F2CE25EE5B5C008F8E80 /* NCGlobal.swift */,
3519+
F7C630702FFE206100257EEB /* NCMediaMetadataBackgroundProcessor.swift */,
35073520
F718E2572DF2D5C3004038AF /* NCBackgroundLocationUploadManager.swift */,
35083521
F7E402282BA85D1D007E5609 /* PrivacyInfo.xcprivacy */,
35093522
F73CB5771ED46807005F2A5A /* NCBridgeSwift.h */,
@@ -4368,6 +4381,7 @@
43684381
F76882372C0DD22F001CF441 /* NCPreferences.swift in Sources */,
43694382
F73EF7E52B02266D0087E6E9 /* NCManageDatabase+Trash.swift in Sources */,
43704383
F7CAFE232F17A37C00DB35A5 /* ProgressQuantizer.swift in Sources */,
4384+
F764C3E42FFB7DFA00029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift in Sources */,
43714385
F71F6D0D2B6A6A5E00F1EB15 /* ThreadSafeArray.swift in Sources */,
43724386
F763D2A32A249C4500A3C901 /* NCManageDatabase+Capabilities.swift in Sources */,
43734387
F749B656297B0F2400087535 /* NCManageDatabase+Avatar.swift in Sources */,
@@ -4479,6 +4493,7 @@
44794493
F7A0D1362591FBC5008F8A13 /* String+Extension.swift in Sources */,
44804494
F7236DDE2F7C00E600F9D722 /* HudIndeterminateBannerView.swift in Sources */,
44814495
F7EDE4D6262D7B9600414FE6 /* NCListCell.swift in Sources */,
4496+
F764C3E12FFB7DFA00029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift in Sources */,
44824497
F74B6D982A7E239A00F03C5F /* NCManageDatabase+Chunk.swift in Sources */,
44834498
F7CF06872E1127460063AD04 /* NCManageDatabase+CreateMetadata.swift in Sources */,
44844499
F7FDFF722E437E55000D7688 /* NCAccountRequest.swift in Sources */,
@@ -4635,6 +4650,7 @@
46354650
F757CC8329E7F88B00F31428 /* NCManageDatabase+Groupfolders.swift in Sources */,
46364651
F73EF7A82B0223900087E6E9 /* NCManageDatabase+Comments.swift in Sources */,
46374652
F74B6D962A7E239A00F03C5F /* NCManageDatabase+Chunk.swift in Sources */,
4653+
F764C3E22FFB7DFA00029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift in Sources */,
46384654
F711A4E32AF9310400095DD8 /* NCUtility+Image.swift in Sources */,
46394655
F749B652297B0F2400087535 /* NCManageDatabase+Avatar.swift in Sources */,
46404656
F763D29E2A249C4500A3C901 /* NCManageDatabase+Capabilities.swift in Sources */,
@@ -4785,6 +4801,7 @@
47854801
F7CDB5C52FA33CA300F72306 /* NCMediaViewerModel.swift in Sources */,
47864802
F7CDB5C62FA33CA300F72306 /* NCMediaViewerView.swift in Sources */,
47874803
F7CDB5CC2FA33CA300F72306 /* NCNextcloudMediaViewerLoader.swift in Sources */,
4804+
F7C630712FFE206100257EEB /* NCMediaMetadataBackgroundProcessor.swift in Sources */,
47884805
F76341182EBE0BC60056F538 /* NCNetworking+NextcloudKitDelegate.swift in Sources */,
47894806
F79377052FBD86AF00DE56DE /* NCMediaViewerFloatingTitleView.swift in Sources */,
47904807
F78A18B823CDE2B300F681F3 /* NCViewerRichWorkspace.swift in Sources */,
@@ -4866,7 +4883,7 @@
48664883
F7D4BF4D2CA2E8D800A5E746 /* TOPasscodeViewController.m in Sources */,
48674884
F75C0C4823D1FAE300163CC8 /* NCRichWorkspaceCommon.swift in Sources */,
48684885
AAE330042D2ED20200B04903 /* NCShareNavigationTitleSetting.swift in Sources */,
4869-
F71CFA672F2A07DB007A3AE9 /* NCMedia+Netwoking.swift in Sources */,
4886+
F71CFA672F2A07DB007A3AE9 /* NCMediaNetwork.swift in Sources */,
48704887
F7DF7B422F1A36C100514020 /* HelperBanner.swift in Sources */,
48714888
F78ACD4A21903F850088454D /* NCTrashListCell.swift in Sources */,
48724889
F7386E482DA90E0F009A00F6 /* NCAppVersionManager.swift in Sources */,
@@ -4940,6 +4957,7 @@
49404957
F768823E2C0DD305001CF441 /* LazyView.swift in Sources */,
49414958
F7CAFE1B2F16AA8D00DB35A5 /* main.swift in Sources */,
49424959
F3E173B02C9AF637006D177A /* ScreenAwakeManager.swift in Sources */,
4960+
F764C3E52FFB7DFA00029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift in Sources */,
49434961
F747EB0D2C4AC1FF00F959A8 /* NCCollectionViewCommon+CollectionViewDelegateFlowLayout.swift in Sources */,
49444962
F765F73125237E3F00391DBE /* NCRecent.swift in Sources */,
49454963
F76B3CCE1EAE01BD00921AC9 /* NCBrand.swift in Sources */,
@@ -4980,6 +4998,7 @@
49804998
F7637D802FE28CBF00F4F90E /* NCContextMenuActions.swift in Sources */,
49814999
AAFC0D092F9AA10000F0A001 /* NCFocusedAutoUploadCloudAnimation.swift in Sources */,
49825000
AAFC0D0B2F9AA10000F0A001 /* NCAutoUploadCounter.swift in Sources */,
5001+
F764C3E72FFB846D00029FD5 /* NCMediaMetadataBackfill.swift in Sources */,
49835002
F760A4862FE959F1001B212E /* NCTransferCoordinator.swift in Sources */,
49845003
F36E64F72B9245210085ABB5 /* NCCollectionViewCommon+SelectTabBarDelegate.swift in Sources */,
49855004
F79A65C62191D95E00FF6DCC /* NCSelect.swift in Sources */,
@@ -5128,6 +5147,7 @@
51285147
files = (
51295148
F78A10C129322E8A008499B8 /* NCManageDatabase+Directory.swift in Sources */,
51305149
F73EF7C12B02250B0087E6E9 /* NCManageDatabase+GPS.swift in Sources */,
5150+
F764C3E32FFB7DFA00029FD5 /* NCManageDatabase+MediaMetadataBackfill.swift in Sources */,
51315151
F7F1FB9D2E27CE7200C79E20 /* NCNetworking.swift in Sources */,
51325152
F7A8D73528F17E16008BBE1C /* NCManageDatabase.swift in Sources */,
51335153
F3F442F02DDE2A7700FD701F /* NCMetadataPermissions.swift in Sources */,

iOSClient/AppDelegate+AppProcessing.swift

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ extension AppDelegate {
2626
}
2727
}
2828

29-
// Handles the BGProcessingTask lifecycle for weekly cleanup or background synchronization.
30-
//
31-
// The function:
32-
// - validates background Realm availability,
33-
// - schedules the next processing task,
34-
// - executes either weekly cleanup or background sync,
35-
// - cooperates with BGTask expiration by cancelling the Swift task,
36-
// - reports success only if the work completes without cancellation.
37-
//
38-
// - Parameter task: The system-provided background processing task.
29+
/// Handles the lifecycle of the app processing background task.
30+
///
31+
/// The task opens the background database, schedules its next execution, and then runs either
32+
/// the weekly maintenance cleanup or the background synchronization pipeline. The sync pipeline
33+
/// performs auto-upload, media metadata backfill, and placeholder hydration for the active account.
34+
///
35+
/// The underlying Swift task is cancelled when iOS expires the background execution time, and the
36+
/// processing task is marked successful only when all scheduled work finishes without cancellation.
37+
///
38+
/// - Parameter task: The system-provided background processing task.
3939
func handleProcessingTask(_ task: BGProcessingTask) {
4040
nkLog(tag: self.global.logTagTask, emoji: .start, message: "Start processing task")
4141

@@ -77,16 +77,79 @@ extension AppDelegate {
7777
}
7878

7979
NCPreferences().setDoneCleaningWeek()
80+
8081
nkLog(tag: self.global.logTagBgSync, emoji: .stop, message: "Stop cleaning week")
82+
8183
return true
8284
} else {
8385
await NCAutoUpload.shared.autoUploadBackgroundSync()
84-
return !Task.isCancelled
86+
87+
guard !Task.isCancelled else {
88+
return false
89+
}
90+
91+
guard let account = await NCManageDatabase.shared.getActiveTableAccountAsync() else {
92+
return false
93+
}
94+
95+
let limit = 500
96+
let mediaProcessor = NCMediaMetadataBackgroundProcessor()
97+
98+
nkLog(tag: self.global.logTagMediaBackfill,
99+
emoji: .start,
100+
message: "Start media metadata backfill")
101+
102+
let backfillStatus = await mediaProcessor.runBackfill(
103+
account: account,
104+
limit: limit
105+
) { offset, inserted, updated in
106+
nkLog(tag: self.global.logTagMediaBackfill,
107+
emoji: .info,
108+
message: "Media metadata backfill progress: offset \(offset) - inserted \(inserted) - updated \(updated)")
109+
}
110+
111+
nkLog(tag: self.global.logTagMediaBackfill,
112+
emoji: backfillStatus.isSuccessful ? .stop : .error,
113+
message: backfillStatus.logMessage)
114+
115+
guard backfillStatus.isSuccessful,
116+
!Task.isCancelled else {
117+
return false
118+
}
119+
120+
nkLog(tag: self.global.logTagMediaPlaceholder,
121+
emoji: .start,
122+
message: "Start media metadata placeholder hydration")
123+
124+
let hydrationStatus = await mediaProcessor.runPlaceholderHydration(
125+
account: account,
126+
limit: limit
127+
) { succeeded in
128+
nkLog(tag: self.global.logTagMediaPlaceholder,
129+
emoji: .info,
130+
message: "Media metadata placeholder hydration progress: succeeded \(succeeded) - limit \(limit)")
131+
}
132+
133+
nkLog(tag: self.global.logTagMediaPlaceholder,
134+
emoji: hydrationStatus.isSuccessful ? .stop : .error,
135+
message: hydrationStatus.logMessage)
136+
137+
guard hydrationStatus.isSuccessful,
138+
!Task.isCancelled else {
139+
return false
140+
}
141+
142+
return true
85143
}
86144
}
87145

88146
Task {
89147
let success = await processingTask.value
148+
149+
nkLog(tag: self.global.logTagTask,
150+
emoji: success ? .stop : .error,
151+
message: "Stop processing task")
152+
90153
task.setTaskCompleted(success: success)
91154
}
92155

0 commit comments

Comments
 (0)