File tree 2 files changed +24
-0
lines changed
ownCloudSDK/Core/Sync/Actions/Upload
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 20
20
#import " OCSyncActionUpload.h"
21
21
#import " OCItem+OCFileURLMetadata.h"
22
22
#import " OCCore+NameConflicts.h"
23
+ #import " OCCore+Internal.h"
23
24
24
25
#import < CoreServices/CoreServices.h>
25
26
@@ -66,6 +67,22 @@ - (nullable NSProgress *)importFileNamed:(nullable NSString *)newFileName at:(OC
66
67
}
67
68
}
68
69
70
+ // Replace existing
71
+ NSNumber *forceReplace = options[OCConnectionOptionForceReplaceKey];
72
+ if ((forceReplace != nil ) && forceReplace.boolValue )
73
+ {
74
+ NSError *error = nil ;
75
+ OCItem *existingItem = nil ;
76
+
77
+ existingItem = [self cachedItemInParentLocation: parentItem.location withName: newFileName isDirectory: NO error: &error];
78
+
79
+ if (existingItem != nil )
80
+ {
81
+ // Schedule as local modification instead
82
+ return ([self reportLocalModificationOfItem: existingItem parentItem: parentItem withContentsOfFileAtURL: inputFileURL isSecurityScoped: isSecurityScoped options: options placeholderCompletionHandler: placeholderCompletionHandler resultHandler: resultHandler]);
83
+ }
84
+ }
85
+
69
86
// Create placeholder item and fill fields required by -[NSFileProviderExtension importDocumentAtURL:toParentItemIdentifier:completionHandler:] completion handler
70
87
placeholderItem = [OCItem placeholderItemOfType: OCItemTypeFile];
71
88
Original file line number Diff line number Diff line change @@ -510,6 +510,13 @@ - (NSError *)resolveIssue:(OCSyncIssue *)issue withChoice:(OCSyncIssueChoice *)c
510
510
options[OCConnectionOptionForceReplaceKey] = @(YES );
511
511
self.options = options;
512
512
513
+ OCItem *preExistingItem = [self _preExistingItem ];
514
+ if (preExistingItem != nil )
515
+ {
516
+ // Remove (possible) duplicate item from database
517
+ syncContext.removedItems = @[ preExistingItem ];
518
+ }
519
+
513
520
syncContext.updateStoredSyncRecordAfterItemUpdates = YES ;
514
521
515
522
[syncContext transitionToState: OCSyncRecordStateReady withWaitConditions: nil ];
You can’t perform that action at this time.
0 commit comments