Copying big size file, How I can know when file has finished completely?

3,391 views
Skip to first unread message

Manuel Jesús Parra Royón

unread,
May 8, 2013, 10:07:20 AM5/8/13
to watchdo...@googlegroups.com
Hi, WatchDog give me this log:

2013-05-08 15:55:11 - Modified directory: /private/tmp/mw
2013-05-08 15:55:11 - Created file: /private/tmp/mw/ax.zip
2013-05-08 15:55:15 - Modified file: /private/tmp/mw/ax.zip
2013-05-08 15:55:15 - Modified file: /private/tmp/mw/ax.zip
.....
Two minutes after
.... 
2013-05-08 15:55:46 - Modified file: /private/tmp/mw/ax.zip
2013-05-08 15:55:47 - Modified file: /private/tmp/mw/ax.zip

I copy a file from random folder to folder watchdogg'ed is a long size file.
During the copy Watchdog Module in python always say me Modified file ... , until file is completely copied to the folder and stop giving me more messages, but, 
There are a event to catch that detect when file has finished?

Thanks in advance.



Nik Kolev

unread,
May 17, 2013, 3:17:56 PM5/17/13
to watchdo...@googlegroups.com
I just discovered watchdog, so I am not sure if watchdog has what you are asking for built-in. But you should be able to decide when the file finished copying by observing that the target file size is stable for a certain amount of time.

Manuel Jesús Parra Royón

unread,
May 18, 2013, 5:59:15 AM5/18/13
to watchdo...@googlegroups.com
Ok, thanks Nik, yes I solved it, by polling this event.


--
You received this message because you are subscribed to a topic in the Google Groups "watchdog-python" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/watchdog-python/qvwHNJK2PKI/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to watchdog-pyth...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Laurent LAPORTE

unread,
May 19, 2013, 9:11:21 AM5/19/13
to watchdo...@googlegroups.com
Hi,

This is a classic issue (it is worse in FTP).

IMO, the best way is to copy your big file to the watch directory using a temporary (and possibly hidden) name. Then to rename/move it when it is finished.

cp work_dir/my_big.zip watched_dir/.my_big_zip.tmp
mv watched_dir/.my_big_zip.tmp watched_dir/my_big.zip

Configure your watchdog to ignore .*.tmp files...

------- Laurent.

John Graves

unread,
Feb 26, 2014, 5:31:27 PM2/26/14
to watchdo...@googlegroups.com
Could you share your polling code Manuel?

Manuel Jesús Parra Royón

unread,
Feb 26, 2014, 5:40:09 PM2/26/14
to watchdo...@googlegroups.com

Yes, but give me just a few hours, and I can pass my code. on to you

John Graves

unread,
Feb 26, 2014, 8:50:52 PM2/26/14
to watchdo...@googlegroups.com

Thomas Amland

unread,
Mar 5, 2014, 11:01:28 AM3/5/14
to watchdo...@googlegroups.com
Try opening the file for writing. If it fails then a different process is keeping it opened and is probably going to write more.

Chris Nyland

unread,
Mar 20, 2014, 2:43:11 PM3/20/14
to watchdo...@googlegroups.com
John I am interested what os are you on. I recently coding something up for a windows 2008 R2 where we are dumping sometimes large ish files 75MB compressed into a directory and I am using the on_modified event and haven't seen any problems. Is my definition of large to small or are you guys running a different os?
 
Chris
Reply all
Reply to author
Forward
0 new messages