how to detect if a file is complete

Marcel van Kervinck marcelk at brick.bitpit.net
Thu Apr 11 16:30:01 EDT 2002


harm <harm at laatje.dhs.org> wrote:
> Hi all,

> I want to copy some files from one dir to another using python. 
> The files are copied onto my linux box via a samba-share.

> I want to write a python script which checks a dir and copies all
> files to another dir. But there is the possibility that the file is
> not yet complete. (This are rather large Postscript files >100mb).
> Therefore I need to detect if the file is complete.

> The files are copied on the samba-share by Adobe Acrobat Distiller,
> therefore i cannot save some check file like $FILENAME.complete...

> Is there some other way (using python) to detect if the file is
> complete?

If you do not want a sloppy approach that involves
probing or running fuser, and if you control the writer,
then the default way is this: Copy the file under a dummy 
name first, and after completion rename it to its 
final name. Renaming is atomic, so by the time the
receiver sees the file, it will be complete.

	Marcel
--  _   _
  _| |_|_|
 |_    |_     marcelk at bitpit.net
         |_|  Marcel van Kervinck



More information about the Python-list mailing list