Bug 143968

Summary: moveFile should overwrite existing files
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: WebCore Misc.Assignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, beidson
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch andersca: review+

Description Alex Christensen 2015-04-20 15:12:16 PDT
When compiling content extensions, the call to moveFile fails often because the file already exists.
Comment 1 Alex Christensen 2015-04-20 15:28:39 PDT
Created attachment 251193 [details]
Patch
Comment 2 Brady Eidson 2015-04-20 16:01:14 PDT
Comment on attachment 251193 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=251193&action=review

> Source/WebCore/platform/mac/FileSystemMac.mm:44
> +@implementation WebFileManagerDelegate
> +- (BOOL)fileManager:(NSFileManager *)fileManager shouldProceedAfterError:(NSError *)error movingItemAtURL:(NSURL *)srcURL toURL:(NSURL *)dstURL

Add an empty line here please.
Comment 3 Anders Carlsson 2015-04-20 16:05:51 PDT
Comment on attachment 251193 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=251193&action=review

> Source/WebCore/platform/mac/FileSystemMac.mm:90
> +    RetainPtr<WebFileManagerDelegate> delegate = adoptNS([[WebFileManagerDelegate alloc] init]);
> +    [[NSFileManager defaultManager] setDelegate:delegate.get()];

Don't set a custom delegate on the default manager, just create a new manager instead.
Comment 4 Alex Christensen 2015-04-20 16:23:34 PDT
Created attachment 251201 [details]
Patch
Comment 5 Anders Carlsson 2015-04-20 16:25:18 PDT
Comment on attachment 251201 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=251201&action=review

> Source/WebCore/platform/mac/FileSystemMac.mm:50
> +    return [error code] == NSFileWriteFileExistsError;

Dot syntax.

> Source/WebCore/platform/mac/FileSystemMac.mm:91
> +    RetainPtr<NSFileManager> manager = adoptNS([[NSFileManager alloc] init]);
> +    RetainPtr<WebFileManagerDelegate> delegate = adoptNS([[WebFileManagerDelegate alloc] init]);

Just use auto here.

> Source/WebCore/platform/mac/FileSystemMac.mm:92
> +    [manager.get() setDelegate:delegate.get()];

No need for .get() in manager.get().

> Source/WebCore/platform/mac/FileSystemMac.mm:94
> +    return [manager.get() moveItemAtURL:[NSURL fileURLWithPath:oldPath] toURL:[NSURL fileURLWithPath:newPath] error:nil];

Same thing here.
Comment 6 Alex Christensen 2015-04-20 16:40:22 PDT
http://trac.webkit.org/changeset/183035