[PLUG] Moving a file while it's being copied

Eric Wilhelm scratchcomputing at gmail.com
Mon Dec 26 16:30:15 UTC 2005


# from Matt Alexander
# on Monday 26 December 2005 08:12 am:

>I'm guessing that this
>works because as the data blocks are being written to disk, I only
> changed which directory contained the inode for the file.

Yes, as long as you're on the same partition and the program has an open 
file descriptor.  The same goes for deleting a file while reading it 
(or writing for that matter (a common strategy for temporary files.)

Note that some programs will use a temp file during download and then 
write to the final location upon completion, so I wouldn't make a habit 
of this because it's very dependent on the internals of the program 
writing the file.  Vim is a good counter example:  By default it moves 
the file to a backup filename, writes a new file with the same name, 
and then deletes the backup.  So, moving a file that it has open for 
editing will mean that you save in the old location unless you have 
setup your config to do otherwise.

--Eric
-- 
Peer's Law: The solution to the problem changes the problem.
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------



More information about the PLUG mailing list