Bug 158473

Summary: [GLIB] Implement hardLinkOrCopyFile() in FileSystemGlib
Product: WebKit Reporter: Carlos Garcia Campos <cgarcia>
Component: PlatformAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bugs-noreply
Priority: P2 Keywords: Gtk
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch mcatanzaro: review+

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>