<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>192562</bug_id>
          
          <creation_ts>2018-12-10 11:32:58 -0800</creation_ts>
          <short_desc>[GLib] FileSystem::moveFile() should fall back to copying</short_desc>
          <delta_ts>2018-12-10 12:47:27 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>Other</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>154553</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Adrian Perez">aperez</reporter>
          <assigned_to name="Adrian Perez">aperez</assigned_to>
          <cc>cgarcia</cc>
    
    <cc>commit-queue</cc>
    
    <cc>darin</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>mmaxfield</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
    
    <cc>zan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1486635</commentid>
    <comment_count>0</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2018-12-10 11:32:58 -0800</bug_when>
    <thetext>Note that:

 - Cocoa (in “Source/WebCore/platform/cocoa/FileSystemCocoa.mm”) uses
   [NSFileManager movItemAtURL:toURL:], which falls back to copying, as per
   https://developer.apple.com/documentation/foundation/nsfilemanager/1414750-moveitematurl?language=objc 

 - Windows (in “Source/WebCore/platform/win/FileSystemWin.cpp”) uses
   MoveFileEx(), passing flags MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING

But in the other hand:

 - “Source/WebCore/platform/posix/FileSystemPOSIX.cpp” uses a plain
   rename(2), which does NOT fall-back to copying.

 - “Source/WebCore/platform/glib/FileSystemGlib.cpp” uses g_rename(),
   which ends up calling rename(2) -- why this does not simply use
   the POSIX implmentation beats me ¯\_(ツ)_/¯

While working on the content extensions code, I have noticed that compiling
a content extension involves creating a temporary file, and then moving it
to its final location. For the GLib-based ports (GTK+, WPE) on Unix, the
temporary file will be created under “/tmp”, and then FileSystem::moveFile()
is used to place it in its final location, typically under the user&apos;s $HOME
directory.

There is a catch, though: frequently “/tmp” is on a different mount point
than the final location! This is *very* often true in modern GNU/Linux
distributions that have “/tmp” on tmpfs. Or, even if “/tmp” is the same
file system as “/”, not uncommonly “/home” can be a separate file system
itself.

To me it is quite clear that FileSyste::moveFile() has to fall-back to
copying, otherwise anything that makes use if this function will be far
too easy to randomly break in unexptected ways.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1486639</commentid>
    <comment_count>1</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2018-12-10 11:42:11 -0800</bug_when>
    <thetext>For FileSystemGLib I am planning to rewrite the function to use
g_file_move(), which does implements a copy+delete fallback.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1486649</commentid>
    <comment_count>2</comment_count>
      <attachid>356977</attachid>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2018-12-10 11:56:08 -0800</bug_when>
    <thetext>Created attachment 356977
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1486673</commentid>
    <comment_count>3</comment_count>
      <attachid>356977</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2018-12-10 12:46:36 -0800</bug_when>
    <thetext>Comment on attachment 356977
Patch

Clearing flags on attachment: 356977

Committed r239043: &lt;https://trac.webkit.org/changeset/239043&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1486674</commentid>
    <comment_count>4</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2018-12-10 12:46:38 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1486676</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-12-10 12:47:27 -0800</bug_when>
    <thetext>&lt;rdar://problem/46604998&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>356977</attachid>
            <date>2018-12-10 11:56:08 -0800</date>
            <delta_ts>2018-12-10 12:46:36 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-192562-20181210215607.patch</filename>
            <type>text/plain</type>
            <size>1748</size>
            <attacher name="Adrian Perez">aperez</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjM5MDM3CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggZjMwOWNkM2EzNTViZDYx
YjY1NjAwZmU0YWUzZDkwMDE5MTVkM2EzMi4uOWVmNDM4NTFiNGU3ZTdjNjQzYzQyYjRjMTYyZGE1
ZmRhZTU3NWViYiAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE2IEBACisyMDE4LTEyLTEwICBBZHJp
YW4gUGVyZXogZGUgQ2FzdHJvICA8YXBlcmV6QGlnYWxpYS5jb20+CisKKyAgICAgICAgW0dMaWJd
IEZpbGVTeXN0ZW06Om1vdmVGaWxlKCkgc2hvdWxkIGZhbGw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