----- Original Message -----

> From: "Boris Zbarsky" <bzbar...@mit.edu>
> To: dev-platform@lists.mozilla.org
> Sent: Saturday, April 26, 2014 6:03:42 PM
> Subject: Re: OS.File design issue from bug 961080 (making downloads respect
> umask)

> On 4/26/14, 11:32 AM, Zack Weinberg wrote:
> > it might be better to just create files in the ultimate target
> > directory if we aren't already.

> We create the file before the user has picked the ultimate target directory.
Right, so we should use the file that we started downloading to as a cache. 

You stat downloading the file to the temp location. 
Once the user selects the final location, you open the file in the final 
location and start copying the file from the temp location to the final 
location. 
Eventually, your copy should catch up with your download, in which case you can 
stop writing to the temp location and resume writing to the final location. 
In the worst case this has the disadvantage of requiring twice the amount of 
disk space as the downloaded file. 

The other approach, is to do what we're doing now (download to temp, move to 
final) and then attempt to fixup the group ownership after the move. There are 
corner cases where this won't work (you can create directories that are 
writable, but where you can't examine the directory to determine if it has the 
group sticky bit set or not). 

You might be able to create a dummy destination file, read the ownership of 
this dummy destination file, remove it, fixup the ownership of the temp file an 
then move it to the destination, but that may cause other problems (for 
example, if the directory had watchers that were performing actions when new 
files show up). 

And you could do a hybrid approach where if you can determine what the correct 
group should be, then you fix it up on the temp file and move it in. And if you 
can't determine the correct group, then you copy it in. 

Dave Hylands 
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to