Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# ChangeLog

## Release version 11.4.5 (January 2021)

- Fix: Crash in Detail View (#855)
- Fix: Upload Improvements (PR #857)

## Release version 11.4.4 (End-November 2020)

- Fix: iPad on iOS 12 (#4293)
Expand Down
2 changes: 1 addition & 1 deletion ownCloud File Provider/FileProviderEnumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{
__weak FileProviderExtension *_fileProviderExtension;

OCCore *_core;
__weak OCCore *_core;
OCBookmark *_bookmark;
NSFileProviderItemIdentifier _enumeratedItemIdentifier;

Expand Down
10 changes: 9 additions & 1 deletion ownCloud File Provider/FileProviderEnumerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,15 @@ - (void)_startQuery
if ((_core == nil) && (_query == nil))
{
[[OCCoreManager sharedCoreManager] requestCoreForBookmark:_bookmark setup:nil completionHandler:^(OCCore *core, NSError *error) {
self->_core = core;
if (self->_core != nil)
{
// Already has a core - balance duplicate requested core
[[OCCoreManager sharedCoreManager] returnCoreForBookmark:core.bookmark completionHandler:nil];
}
else
{
self->_core = core;
}

if (error != nil)
{
Expand Down
4 changes: 2 additions & 2 deletions ownCloud File Provider/FileProviderExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

@interface FileProviderExtension : NSFileProviderExtension <OCCoreDelegate, OCClassSettingsSupport, OCLogTagging>
{
OCCore *_core;
__weak OCCore *_core;
OCBookmark *_bookmark;
}

@property(strong,nonatomic,readonly) OCCore *core;
@property(weak,nonatomic,readonly) OCCore *core;
@property(strong,nonatomic,readonly) OCBookmark *bookmark;

@end
Expand Down
123 changes: 88 additions & 35 deletions ownCloud File Provider/FileProviderExtension.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ - (instancetype)init
{
[self setupCrashReporting];

[OCLogger logLevel]; // Make sure +logLevel is called in File Provider, to properly set up the log level

NSDictionary *bundleInfoDict = [[NSBundle bundleForClass:[FileProviderExtension class]] infoDictionary];

OCCoreManager.sharedCoreManager.memoryConfiguration = OCCoreMemoryConfigurationMinimum;
Expand Down Expand Up @@ -128,6 +130,7 @@ - (void)dealloc

OCLogDebug(@"Returning OCCore for FileProvider %@", self);
[[OCCoreManager sharedCoreManager] returnCoreForBookmark:self.bookmark completionHandler:nil];
_core = nil;
}
}

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

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

if (isSpecialItem)
{
Expand All @@ -953,73 +956,123 @@ - (NSProgress *)fetchThumbnailsForItemIdentifiers:(NSArray<NSFileProviderItemIde
#pragma mark - Core
- (OCBookmark *)bookmark
{
OCBookmark *bookmark = nil;

@synchronized(self)
{
if (_bookmark == nil)
bookmark = _bookmark;
}

if (bookmark == nil)
{
NSFileProviderDomainIdentifier domainIdentifier;

if ((domainIdentifier = self.domain.identifier) != nil)
{
NSFileProviderDomainIdentifier domainIdentifier;
NSUUID *bookmarkUUID = [[NSUUID alloc] initWithUUIDString:domainIdentifier];

if ((domainIdentifier = self.domain.identifier) != nil)
{
NSUUID *bookmarkUUID = [[NSUUID alloc] initWithUUIDString:domainIdentifier];
bookmark = [[OCBookmarkManager sharedBookmarkManager] bookmarkForUUID:bookmarkUUID];

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

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

[[OCBookmarkManager sharedBookmarkManager] loadBookmarks];
bookmark = [[OCBookmarkManager sharedBookmarkManager] bookmarkForUUID:bookmarkUUID];

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

if (_bookmark == nil)
{
OCLogError(@"Error retrieving bookmark for domain %@ (UUID %@) - final", OCLogPrivate(self.domain.displayName), OCLogPrivate(self.domain.identifier));
}
@synchronized(self)
{
if ((_bookmark == nil) && (bookmark != nil))
{
_bookmark = bookmark;
}
}
}
}

return (_bookmark);
return (bookmark);
}

- (OCCore *)core
{
OCLogDebug(@"FileProviderExtension[%p].core[enter]: _core=%p, bookmark=%@", self, _core, self.bookmark);

OCBookmark *bookmark = self.bookmark;
__block OCCore *retCore = nil;

@synchronized(self)
{
if (_core == nil)
retCore = _core;
}

if (retCore == nil)
{
if (bookmark != nil)
{
if (self.bookmark != nil)
{
OCLogDebug(@"Requesting OCCore for FileProvider %@", self);
OCLogDebug(@"Requesting OCCore for FileProvider %@", self);

OCSyncExec(waitForCore, {
[[OCCoreManager sharedCoreManager] requestCoreForBookmark:self.bookmark setup:^(OCCore *core, NSError *error) {
self->_core = core;
core.delegate = self;
} completionHandler:^(OCCore *core, NSError *error) {
OCSyncExec(waitForCore, {
__block BOOL hasCore = NO;

[[OCCoreManager sharedCoreManager] requestCoreForBookmark:bookmark setup:^(OCCore *core, NSError *error) {
@synchronized(self)
{
hasCore = (self->_core != nil);

if (!hasCore)
{
self->_core = core;
core.delegate = self;
retCore = core;
}
else
{
retCore = self->_core;
}
}
} completionHandler:^(OCCore *core, NSError *error) {
if (!hasCore)
{
self->_core = core;

if ((self->_messagePresenter = [[NotificationMessagePresenter alloc] initForBookmarkUUID:core.bookmark.uuid]) != nil)
{
[core.messageQueue addPresenter:self->_messagePresenter];
}
}
else
{
retCore = self->_core;
}

OCSyncExecDone(waitForCore);
}];
});
}
}
OCSyncExecDone(waitForCore);

if (_core == nil)
{
OCLogError(@"Error getting core for domain %@ (UUID %@)", OCLogPrivate(self.domain.displayName), OCLogPrivate(self.domain.identifier));
if (hasCore)
{
// Balance out unrequired request for core
[OCCoreManager.sharedCoreManager returnCoreForBookmark:bookmark completionHandler:nil];
}
}];
});
}
}

return (_core);
if (retCore == nil)
{
OCLogError(@"Error getting core for domain %@ (UUID %@)", OCLogPrivate(self.domain.displayName), OCLogPrivate(self.domain.identifier));
}

OCLogDebug(@"FileProviderExtension[%p].core[leave]: _core=%p, bookmark=%@", self, retCore, bookmark);

return (retCore);

}

- (void)core:(OCCore *)core handleError:(NSError *)error issue:(OCIssue *)issue
Expand Down
51 changes: 40 additions & 11 deletions ownCloud File Provider/FileProviderServiceSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@
#import <ownCloudApp/ownCloudApp.h>
#import <ownCloudSDK/ownCloudSDK.h>

@interface OCCore (setNeedsToProcessSyncRecords)
- (void)setNeedsToProcessSyncRecords;
@end

@interface FileProviderServiceSource () <NSXPCListenerDelegate, OCFileProviderServicesHost>
{
NSFileProviderServiceName _serviceName;
NSXPCListener *_listener;
OCBookmark *_bookmark;
__weak OCCore *_core;
}
@end

Expand All @@ -37,13 +43,21 @@ - (instancetype)initWithServiceName:(NSString *)serviceName extension:(FileProvi
{
_serviceName = serviceName;
_fileProviderExtension = fileProviderExtension;
_bookmark = _fileProviderExtension.bookmark;
}

return (self);
}

- (void)dealloc
{
OCLogDebug(@"FileProviderServiceSource Dealloc");

if ((_bookmark != nil) && (_core != nil))
{
[OCCoreManager.sharedCoreManager returnCoreForBookmark:_bookmark completionHandler:nil];
}

[_listener invalidate];
}

Expand Down Expand Up @@ -81,27 +95,42 @@ - (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConne
[weakConnection invalidate];
};

[self.fileProviderExtension.core scheduleInCoreQueue:^{
[newConnection resume];
OCLogDebug(@"FileProviderServiceSource[%p].shouldAcceptNewConnection[enter]", self.fileProviderExtension);

[OCCoreManager.sharedCoreManager requestCoreForBookmark:_bookmark setup:nil completionHandler:^(OCCore * _Nullable core, NSError * _Nullable error) {
self->_core = core;

[core scheduleInCoreQueue:^{
OCLogDebug(@"FileProviderServiceSource[%p].shouldAcceptNewConnection[done]", self.fileProviderExtension);
[newConnection resume];
}];
}];

OCLogDebug(@"FileProviderServiceSource[%p].shouldAcceptNewConnection[core]: %@", self.fileProviderExtension, self.fileProviderExtension.core);

return (YES);
}

#pragma mark - Service API
- (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
{
return ([_fileProviderExtension.core importItemNamed:newFileName
at:parentItem
fromURL:inputFileURL
isSecurityScoped:isSecurityScoped
options:@{
OCCoreOptionImportByCopying : @(importByCopying),
OCCoreOptionAutomaticConflictResolutionNameStyle : @(nameStyle)
}
placeholderCompletionHandler:^(NSError * _Nullable error, OCItem * _Nullable item) {
return ([_core importItemNamed:newFileName
at:parentItem
fromURL:inputFileURL
isSecurityScoped:isSecurityScoped
options:@{
OCCoreOptionImportByCopying : @(importByCopying),
OCCoreOptionAutomaticConflictResolutionNameStyle : @(nameStyle)
}
placeholderCompletionHandler:^(NSError * _Nullable error, OCItem * _Nullable item) {
completionHandler(error);
} resultHandler:nil]);
}

- (void)processSyncRecordsIfNeeded
{
OCLogDebug(@"Process sync records if needed for %@", _fileProviderExtension.core);
[_core setNeedsToProcessSyncRecords];
}

@end
Loading