Skip to content

Instantly share code, notes, and snippets.

@ssig33
Created November 17, 2010 06:49
Show Gist options
  • Save ssig33/703080 to your computer and use it in GitHub Desktop.
Save ssig33/703080 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
dir = "YOUR_DOWNLOAD_DIR"
config = "/home/YOUR_USER_NAME/.config/transmissioncli/torrents"
while true
flag = false
Dir.entries(dir).each do |f|
if f.split(".").last == "part"
flag = false
break
end
next if File.ftype("#{dir}#{f}") != "file" or f.split(".").last == "part" #f == "." or f == ".." or f == "windows"
Dir.entries(config).each do |t|
flag = true if t =~ /#{f.gsub(/\ /, "\\ ").gsub(/\[/, "\\[").gsub(/\]/, "\\]").gsub(/\(/, "\\(").gsub(/\)/, "\\)")}/
end
end
if flag
`killall transmissioncli`
"killed"
end
sleep 30
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment