Check for file access

Andrew McGregor andrew at indranet.co.nz
Tue Jan 14 12:41:40 EST 2003


--On Tuesday, January 14, 2003 06:56:29 -0800 Brian Bull 
<bbull at pathfire.com> wrote:

> I am writing a daemon to monitor file uploads and mirror the files to
> another server once they have been uploaded.  The files will be
> uploaded via Windows filesharing onto my Redhat server that is running
> Samba.  How can I tell when the file is complete and is ready for
> copying?
>
> I am using a kernel module called 'changedfiles' that alerts me when a
> file is changed.  The only problem is this modules alerts me when the
> file operation begins, not when it ends.  The files that will be
> uploaded are CD images so they will be very large, so I have to have
> some sort of way to "wait" until the file is complete.
>
> I have tried opening the file (with read and write permission), but
> that cancels the upload process.  I guess Windows loses the access to
> the file once the server grabs it.
>
> I have also tried checking the size of the file, but that doesn't work
> because the complete size is reported from the first second the file
> is being uploaded.
>
> Any help here would be really appreciated.  If I am not describing
> this well, let me know and I will try to elaborate more.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>

Wait until the fuser command (not python function, system command) no 
longer shows any task using that file.  The technique it uses is 
complicated (and brute force), so replicating it in python would be quite a 
bit of work.

Andrew





More information about the Python-list mailing list