Bug 158473 - [GLIB] Implement hardLinkOrCopyFile() in FileSystemGlib
Summary: [GLIB] Implement hardLinkOrCopyFile() in FileSystemGlib
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk
Depends on:
Blocks:
 
Reported: 2016-06-07 03:41 PDT by Carlos Garcia Campos
Modified: 2016-06-07 23:50 PDT (History)
1 user (show)

See Also:


Attachments
Patch (1.84 KB, patch)
2016-06-07 03:43 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Patch (2.00 KB, patch)
2016-06-07 04:40 PDT, Carlos Garcia Campos
mcatanzaro: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2016-06-07 03:41:00 PDT
It was added in r199230 to be used by IndexedDB blob support, but never implemented for GLib.
Comment 1 Carlos Garcia Campos 2016-06-07 03:43:06 PDT
Created attachment 280689 [details]
Patch
Comment 2 Adrian Perez 2016-06-07 04:15:00 PDT
Comment on attachment 280689 [details]
Patch

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

Informally reviewed. LGTM with a nit.

> Source/WebCore/platform/glib/FileSystemGlib.cpp:385
> +    if (!link(sourceFilename.get(), destinationFilename.get()))

In Windows the CreateHardLink() function could be used here instead of always copying the file (though it only works in NTFS, see: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363860(v=vs.85).aspx), so please add a TODO comment here to let developers working in Windows that they may want to add the relevant code in the future.
Comment 3 Carlos Garcia Campos 2016-06-07 04:40:55 PDT
Created attachment 280694 [details]
Patch

Add windows implementation too (copied from FileSystemWin.cpp and untested).
Comment 4 Michael Catanzaro 2016-06-07 07:13:26 PDT
Comment on attachment 280694 [details]
Patch

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

> Source/WebCore/platform/glib/FileSystemGlib.cpp:394
> +    return g_file_copy(sourceFile.get(), destinationFile.get(), G_FILE_COPY_NONE, nullptr, nullptr, nullptr, nullptr);

Probably should use G_FILE_COPY_OVERWRITE instead of G_FILE_COPY_NONE?
Comment 5 Carlos Garcia Campos 2016-06-07 10:47:24 PDT
(In reply to comment #4)
> Comment on attachment 280694 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=280694&action=review
> 
> > Source/WebCore/platform/glib/FileSystemGlib.cpp:394
> > +    return g_file_copy(sourceFile.get(), destinationFile.get(), G_FILE_COPY_NONE, nullptr, nullptr, nullptr, nullptr);
> 
> Probably should use G_FILE_COPY_OVERWRITE instead of G_FILE_COPY_NONE?

I don't think so, this is a fallback for link, and link fails if destination exists. I think the posix implementation also fails if destination exists.
Comment 6 Carlos Garcia Campos 2016-06-07 23:50:33 PDT
Committed r201796: <http://trac.webkit.org/changeset/201796>