Script to check if files have been created yet?

General support for problems installing or using Deluge
Post Reply
Formula Juan
Member
Member
Posts: 11
Joined: Mon Oct 28, 2019 6:53 pm

Script to check if files have been created yet?

Post by Formula Juan »

I'm creating a Bash script that automatically creates hardlinks to torrent files.

The thought occurred to me that one possible way that the script might fail to function as intended is if not all the files within the torrent have been created yet. By which I mean, if I was downloading a torrent that contained multiple files, such as a season of a TV series... if my script is triggered once the torrent is added, there's no guarantee that all the files would be created before the script runs. I've thought about adding a delay at the start of the script but again, there's no guarantee that the files would have been partially created with the time frame of the delay.

The obvious thing might be to run the script when the torrent has finished but for various reasons, I'd really rather leave that as the last resort.

So my idea / question is....

Seen as though the .torrent file (within the state folder) contains a list of all the files within the torrent, would it be feasible to create a script that derived a list of files from the .torrent file, and then checked if said files existed within the download folder of the torrent?

Is there a better way of getting a list of files within a torrent, that has only just been added to Deluge, that trying to extract them from the .torrent file?
Post Reply