Bug 143968 - moveFile should overwrite existing files
Summary: moveFile should overwrite existing files
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-20 15:12 PDT by Alex Christensen
Modified: 2015-04-20 16:40 PDT (History)
2 users (show)

See Also:


Attachments
Patch (2.26 KB, patch)
2015-04-20 15:28 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (2.41 KB, patch)
2015-04-20 16:23 PDT, Alex Christensen
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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