Skip to content

Commit 376de85

Browse files
felix-schwarzhosy
andauthored
[milestone/11.4.5] Milestone 11.4.5 (#857)
* - backport OCFileProviderServiceStandby from milestone/11.5 to wake up / keep awake the File Provider while the client session is open * - FileProvider and FileProviderServiceSource - extend logging - add call to +logLevel to properly set up the log level - OCLicenseAppStoreProvider: avoid retain of self in observer block * File Provider fixes: - remove strong instance references to OCCore from FileProviderEnumerator and FileProviderExtension - avoid locking and better handle concurrent requests for bookmarks and cores - keep OCCore alive by also following request/return semantics in FileProviderServiceSource as well - add new processSyncRecordsIfNeeded method to OCFileProviderService protocol to allow triggering sync record processing from OCFileProviderServiceStandby - OCFileProviderServiceStandby: trigger processSyncRecordsIfNeeded whenever the app is brought to the front * - fix crash reported in #855 * - update SDK * - update SDK * - updated to new version 11.4.5 - added release notes for version 11.4.5 - localized shortcuts definition files for all supported languages * do not allow dragging and show contextual menu actions, when table view is in edit mode to do not interrupt the move row action and prevent switching to a new window on the iPad * FileProvider: change log level of bookmark retrieval log message * - Update SDK * - updated short version string to 182 - fixed german translation Co-authored-by: Matthias Hühne <[email protected]>
1 parent e488f87 commit 376de85

36 files changed

+8001
-70
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# ChangeLog
22

3+
## Release version 11.4.5 (January 2021)
4+
5+
- Fix: Crash in Detail View (#855)
6+
- Fix: Upload Improvements (PR #857)
7+
38
## Release version 11.4.4 (End-November 2020)
49

510
- Fix: iPad on iOS 12 (#4293)

ownCloud File Provider/FileProviderEnumerator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
{
2727
__weak FileProviderExtension *_fileProviderExtension;
2828

29-
OCCore *_core;
29+
__weak OCCore *_core;
3030
OCBookmark *_bookmark;
3131
NSFileProviderItemIdentifier _enumeratedItemIdentifier;
3232

ownCloud File Provider/FileProviderEnumerator.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,15 @@ - (void)_startQuery
127127
if ((_core == nil) && (_query == nil))
128128
{
129129
[[OCCoreManager sharedCoreManager] requestCoreForBookmark:_bookmark setup:nil completionHandler:^(OCCore *core, NSError *error) {
130-
self->_core = core;
130+
if (self->_core != nil)
131+
{
132+
// Already has a core - balance duplicate requested core
133+
[[OCCoreManager sharedCoreManager] returnCoreForBookmark:core.bookmark completionHandler:nil];
134+
}
135+
else
136+
{
137+
self->_core = core;
138+
}
131139

132140
if (error != nil)
133141
{

ownCloud File Provider/FileProviderExtension.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121

2222
@interface FileProviderExtension : NSFileProviderExtension <OCCoreDelegate, OCClassSettingsSupport, OCLogTagging>
2323
{
24-
OCCore *_core;
24+
__weak OCCore *_core;
2525
OCBookmark *_bookmark;
2626
}
2727

28-
@property(strong,nonatomic,readonly) OCCore *core;
28+
@property(weak,nonatomic,readonly) OCCore *core;
2929
@property(strong,nonatomic,readonly) OCBookmark *bookmark;
3030

3131
@end

ownCloud File Provider/FileProviderExtension.m

Lines changed: 88 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ - (instancetype)init
4848
{
4949
[self setupCrashReporting];
5050

51+
[OCLogger logLevel]; // Make sure +logLevel is called in File Provider, to properly set up the log level
52+
5153
NSDictionary *bundleInfoDict = [[NSBundle bundleForClass:[FileProviderExtension class]] infoDictionary];
5254

5355
OCCoreManager.sharedCoreManager.memoryConfiguration = OCCoreMemoryConfigurationMinimum;
@@ -128,6 +130,7 @@ - (void)dealloc
128130

129131
OCLogDebug(@"Returning OCCore for FileProvider %@", self);
130132
[[OCCoreManager sharedCoreManager] returnCoreForBookmark:self.bookmark completionHandler:nil];
133+
_core = nil;
131134
}
132135
}
133136

@@ -938,7 +941,7 @@ - (NSProgress *)fetchThumbnailsForItemIdentifiers:(NSArray<NSFileProviderItemIde
938941
{
939942
BOOL isSpecialItem = [itemIdentifier isEqual:self.bookmark.fpServicesURLComponentName];
940943

941-
OCTLogDebug(@[@"FPServices"], @"request for supported services sources for item identifier %@ (%d)", OCLogPrivate(itemIdentifier), isSpecialItem);
944+
OCTLogDebug(@[@"FPServices"], @"request for supported services sources for item identifier %@ (isSpecialItem: %d, core: %@)", OCLogPrivate(itemIdentifier), isSpecialItem, self.core);
942945

943946
if (isSpecialItem)
944947
{
@@ -953,73 +956,123 @@ - (NSProgress *)fetchThumbnailsForItemIdentifiers:(NSArray<NSFileProviderItemIde
953956
#pragma mark - Core
954957
- (OCBookmark *)bookmark
955958
{
959+
OCBookmark *bookmark = nil;
960+
956961
@synchronized(self)
957962
{
958-
if (_bookmark == nil)
963+
bookmark = _bookmark;
964+
}
965+
966+
if (bookmark == nil)
967+
{
968+
NSFileProviderDomainIdentifier domainIdentifier;
969+
970+
if ((domainIdentifier = self.domain.identifier) != nil)
959971
{
960-
NSFileProviderDomainIdentifier domainIdentifier;
972+
NSUUID *bookmarkUUID = [[NSUUID alloc] initWithUUIDString:domainIdentifier];
961973

962-
if ((domainIdentifier = self.domain.identifier) != nil)
963-
{
964-
NSUUID *bookmarkUUID = [[NSUUID alloc] initWithUUIDString:domainIdentifier];
974+
bookmark = [[OCBookmarkManager sharedBookmarkManager] bookmarkForUUID:bookmarkUUID];
965975

966-
_bookmark = [[OCBookmarkManager sharedBookmarkManager] bookmarkForUUID:bookmarkUUID];
976+
if (bookmark == nil)
977+
{
978+
OCLogDebug(@"Error retrieving bookmark for domain %@ (UUID %@) - reloading", OCLogPrivate(self.domain.displayName), OCLogPrivate(self.domain.identifier));
967979

968-
if (_bookmark == nil)
969-
{
970-
OCLogError(@"Error retrieving bookmark for domain %@ (UUID %@) - reloading", OCLogPrivate(self.domain.displayName), OCLogPrivate(self.domain.identifier));
980+
[[OCBookmarkManager sharedBookmarkManager] loadBookmarks];
971981

972-
[[OCBookmarkManager sharedBookmarkManager] loadBookmarks];
982+
bookmark = [[OCBookmarkManager sharedBookmarkManager] bookmarkForUUID:bookmarkUUID];
973983

974-
_bookmark = [[OCBookmarkManager sharedBookmarkManager] bookmarkForUUID:bookmarkUUID];
984+
if (bookmark == nil)
985+
{
986+
OCLogError(@"Error retrieving bookmark for domain %@ (UUID %@) - final", OCLogPrivate(self.domain.displayName), OCLogPrivate(self.domain.identifier));
987+
}
988+
}
975989

976-
if (_bookmark == nil)
977-
{
978-
OCLogError(@"Error retrieving bookmark for domain %@ (UUID %@) - final", OCLogPrivate(self.domain.displayName), OCLogPrivate(self.domain.identifier));
979-
}
990+
@synchronized(self)
991+
{
992+
if ((_bookmark == nil) && (bookmark != nil))
993+
{
994+
_bookmark = bookmark;
980995
}
981996
}
982997
}
983998
}
984999

985-
return (_bookmark);
1000+
return (bookmark);
9861001
}
9871002

9881003
- (OCCore *)core
9891004
{
1005+
OCLogDebug(@"FileProviderExtension[%p].core[enter]: _core=%p, bookmark=%@", self, _core, self.bookmark);
1006+
1007+
OCBookmark *bookmark = self.bookmark;
1008+
__block OCCore *retCore = nil;
1009+
9901010
@synchronized(self)
9911011
{
992-
if (_core == nil)
1012+
retCore = _core;
1013+
}
1014+
1015+
if (retCore == nil)
1016+
{
1017+
if (bookmark != nil)
9931018
{
994-
if (self.bookmark != nil)
995-
{
996-
OCLogDebug(@"Requesting OCCore for FileProvider %@", self);
1019+
OCLogDebug(@"Requesting OCCore for FileProvider %@", self);
9971020

998-
OCSyncExec(waitForCore, {
999-
[[OCCoreManager sharedCoreManager] requestCoreForBookmark:self.bookmark setup:^(OCCore *core, NSError *error) {
1000-
self->_core = core;
1001-
core.delegate = self;
1002-
} completionHandler:^(OCCore *core, NSError *error) {
1021+
OCSyncExec(waitForCore, {
1022+
__block BOOL hasCore = NO;
1023+
1024+
[[OCCoreManager sharedCoreManager] requestCoreForBookmark:bookmark setup:^(OCCore *core, NSError *error) {
1025+
@synchronized(self)
1026+
{
1027+
hasCore = (self->_core != nil);
1028+
1029+
if (!hasCore)
1030+
{
1031+
self->_core = core;
1032+
core.delegate = self;
1033+
retCore = core;
1034+
}
1035+
else
1036+
{
1037+
retCore = self->_core;
1038+
}
1039+
}
1040+
} completionHandler:^(OCCore *core, NSError *error) {
1041+
if (!hasCore)
1042+
{
10031043
self->_core = core;
10041044

10051045
if ((self->_messagePresenter = [[NotificationMessagePresenter alloc] initForBookmarkUUID:core.bookmark.uuid]) != nil)
10061046
{
10071047
[core.messageQueue addPresenter:self->_messagePresenter];
10081048
}
1049+
}
1050+
else
1051+
{
1052+
retCore = self->_core;
1053+
}
10091054

1010-
OCSyncExecDone(waitForCore);
1011-
}];
1012-
});
1013-
}
1014-
}
1055+
OCSyncExecDone(waitForCore);
10151056

1016-
if (_core == nil)
1017-
{
1018-
OCLogError(@"Error getting core for domain %@ (UUID %@)", OCLogPrivate(self.domain.displayName), OCLogPrivate(self.domain.identifier));
1057+
if (hasCore)
1058+
{
1059+
// Balance out unrequired request for core
1060+
[OCCoreManager.sharedCoreManager returnCoreForBookmark:bookmark completionHandler:nil];
1061+
}
1062+
}];
1063+
});
10191064
}
10201065
}
10211066

1022-
return (_core);
1067+
if (retCore == nil)
1068+
{
1069+
OCLogError(@"Error getting core for domain %@ (UUID %@)", OCLogPrivate(self.domain.displayName), OCLogPrivate(self.domain.identifier));
1070+
}
1071+
1072+
OCLogDebug(@"FileProviderExtension[%p].core[leave]: _core=%p, bookmark=%@", self, retCore, bookmark);
1073+
1074+
return (retCore);
1075+
10231076
}
10241077

10251078
- (void)core:(OCCore *)core handleError:(NSError *)error issue:(OCIssue *)issue

ownCloud File Provider/FileProviderServiceSource.m

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@
2020
#import <ownCloudApp/ownCloudApp.h>
2121
#import <ownCloudSDK/ownCloudSDK.h>
2222

23+
@interface OCCore (setNeedsToProcessSyncRecords)
24+
- (void)setNeedsToProcessSyncRecords;
25+
@end
26+
2327
@interface FileProviderServiceSource () <NSXPCListenerDelegate, OCFileProviderServicesHost>
2428
{
2529
NSFileProviderServiceName _serviceName;
2630
NSXPCListener *_listener;
31+
OCBookmark *_bookmark;
32+
__weak OCCore *_core;
2733
}
2834
@end
2935

@@ -37,13 +43,21 @@ - (instancetype)initWithServiceName:(NSString *)serviceName extension:(FileProvi
3743
{
3844
_serviceName = serviceName;
3945
_fileProviderExtension = fileProviderExtension;
46+
_bookmark = _fileProviderExtension.bookmark;
4047
}
4148

4249
return (self);
4350
}
4451

4552
- (void)dealloc
4653
{
54+
OCLogDebug(@"FileProviderServiceSource Dealloc");
55+
56+
if ((_bookmark != nil) && (_core != nil))
57+
{
58+
[OCCoreManager.sharedCoreManager returnCoreForBookmark:_bookmark completionHandler:nil];
59+
}
60+
4761
[_listener invalidate];
4862
}
4963

@@ -81,27 +95,42 @@ - (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConne
8195
[weakConnection invalidate];
8296
};
8397

84-
[self.fileProviderExtension.core scheduleInCoreQueue:^{
85-
[newConnection resume];
98+
OCLogDebug(@"FileProviderServiceSource[%p].shouldAcceptNewConnection[enter]", self.fileProviderExtension);
99+
100+
[OCCoreManager.sharedCoreManager requestCoreForBookmark:_bookmark setup:nil completionHandler:^(OCCore * _Nullable core, NSError * _Nullable error) {
101+
self->_core = core;
102+
103+
[core scheduleInCoreQueue:^{
104+
OCLogDebug(@"FileProviderServiceSource[%p].shouldAcceptNewConnection[done]", self.fileProviderExtension);
105+
[newConnection resume];
106+
}];
86107
}];
87108

109+
OCLogDebug(@"FileProviderServiceSource[%p].shouldAcceptNewConnection[core]: %@", self.fileProviderExtension, self.fileProviderExtension.core);
110+
88111
return (YES);
89112
}
90113

91114
#pragma mark - Service API
92115
- (nullable NSProgress *)importItemNamed:(nullable NSString *)newFileName at:(OCItem *)parentItem fromURL:(NSURL *)inputFileURL isSecurityScoped:(BOOL)isSecurityScoped importByCopying:(BOOL)importByCopying automaticConflictResolutionNameStyle:(OCCoreDuplicateNameStyle)nameStyle placeholderCompletionHandler:(void(^)(NSError * _Nullable error))completionHandler
93116
{
94-
return ([_fileProviderExtension.core importItemNamed:newFileName
95-
at:parentItem
96-
fromURL:inputFileURL
97-
isSecurityScoped:isSecurityScoped
98-
options:@{
99-
OCCoreOptionImportByCopying : @(importByCopying),
100-
OCCoreOptionAutomaticConflictResolutionNameStyle : @(nameStyle)
101-
}
102-
placeholderCompletionHandler:^(NSError * _Nullable error, OCItem * _Nullable item) {
117+
return ([_core importItemNamed:newFileName
118+
at:parentItem
119+
fromURL:inputFileURL
120+
isSecurityScoped:isSecurityScoped
121+
options:@{
122+
OCCoreOptionImportByCopying : @(importByCopying),
123+
OCCoreOptionAutomaticConflictResolutionNameStyle : @(nameStyle)
124+
}
125+
placeholderCompletionHandler:^(NSError * _Nullable error, OCItem * _Nullable item) {
103126
completionHandler(error);
104127
} resultHandler:nil]);
105128
}
106129

130+
- (void)processSyncRecordsIfNeeded
131+
{
132+
OCLogDebug(@"Process sync records if needed for %@", _fileProviderExtension.core);
133+
[_core setNeedsToProcessSyncRecords];
134+
}
135+
107136
@end

0 commit comments

Comments
 (0)