Bug 216392

Summary: WebKitDownload deleting/damaging files it shouldn't touch.
Product: WebKit Reporter: CRL <crl>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bugs-noreply, webkit-bug-importer
Priority: P2    
Version: WebKit Local Build   
Hardware: PC   
OS: Linux   

Description CRL 2020-09-10 18:08:08 PDT
Saving a WebKitDownload to /path/to/filename, which already exists.

/path/to/hardlink is a hard link to /path/to/filename.

(1)
webkit_download_set_destination(wkdl,"file:///path/to/filename");
webkit_download_set_allow_overwrite(wkdl,FALSE);

Bug: The operation fails (as expected), but the existing /path/to/filename is deleted.
 Even if /path/to/filename is write-protected.
 Even if /path/to/filename is actually an empty directory.

(2)
webkit_download_set_destination(wkdl,"file:///path/to/filename");
webkit_download_set_allow_overwrite(wkdl,TRUE);

With everything writeable, the download is saved with a new inode, breaking the hard link. Won't argue the "new inode" -- opinions may differ.  But I would expect the contents of /path/to/hardlink to be untouched.

Bug: The contents of /path/to/hardlink are deleted, leaving an empty file.