Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I made a script in Python that is able to move some files from one folder to another. This is on when the file's are static. My problem comes when the files are "incomplete" because a torrent program is still downloading them.

How can I check with python, before performing the "moving" operation, if the file is incomplete/still downloading, so I know I have to wait performing any operation on that file?

Because if I run my script and the file is still downloading, of couse, I would be moving a corrupted file, which isn't very nice.

So, how can one know if a file is being modified/incomplete in python?

As a torrent client, I am using Tixati.

share|improve this question
    
Most good BitTorrent clients have an option to either suffix partial files with .part or .!ut, or to run a script after downloading themselves. –  grawity Jun 2 at 7:32
    
Couldn't find this option in Tixati (to suffix partial files I mean). One solution that I can think of is using the "trasfer file to directory ones completed" option... but If I download big files it would stess to much the hdd moving files around. –  Con7e Jun 2 at 7:38
    
You'd be surprised at how much a HDD can withstand; moving a chunk of data (mostly sequential reads & writes) is nothing in comparison. However, if you move a file within the partition, it does not move the data – it only removes the file from the old directory and adds to the new one. –  grawity Jun 2 at 7:43
1  
Yes. The directory structure has absolutely no relation to the physical location of the data on disk – when you write some data a file, the OS just puts it wherever it finds a decent chunk of free space. /// At the most basic level, a "directory" has a list of pointers to files; similarly, a "file" has a list of pointers to actual blocks of data. When you move a file, the OS just updates the old directory to remove the pointer to that file, and updates the new directory to add a pointer to the same file. The file itself isn't even touched. –  grawity Jun 2 at 7:50
1  
This only applies when moving/renaming within the same partition, of course – if you have several partitions, whether on the same disk or different ones, (e.g. C:+D:+E: or /+/home+/mnt/movies), each of them has an independent structure, and data needs to be actually moved from one partition to another. (But, again, if you move a huge file between two disks, then it's just a simple sequential read from one, and write to another. It strains the disk a bit less than random seeking.) –  grawity Jun 2 at 7:56

1 Answer 1

You don't need to use a python script to move a file on completion.
Most bittorrent clients can do this automaticlly if you set them up to do so.
An advantage to do it this way is that the client can continue so seed the torrent.

In Tixati you can do it two ways:

  • Open Tixati Settings > Transfers > Local files
    Activate: Upon completion, move to this location:

or

  • Select a torrent.
    Open Options tab.
    Activate: Upon completion, move to this location:
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.