File: staleImages.rb

package info (click to toggle)
amarok 3.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 112,168 kB
  • sloc: cpp: 195,056; xml: 4,322; ansic: 2,634; javascript: 673; ruby: 528; python: 507; sh: 252; makefile: 12
file content (27 lines) | stat: -rwxr-xr-x 779 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env ruby
#
# script to remove stale images in the database
#
# (c) 2006 Roland Gigler <rolandg@web.de>
# License: GNU General Public License V2

system("dcop", "amarok", "playlist", "shortStatusMessage", "Removing stale 'images' entries from the database")

qresult = `dcop amarok collection query "SELECT path FROM images;"`
result = qresult.split( "\n" )

i = 0

result.each do |url|
    #puts "url: #{url}"
    unless FileTest.exist?( url )
        i = i + 1
        url.gsub!(/[']/, '\\\\\'')
        puts "Deleting: #{url}"
        system("dcop", "amarok", "collection", "query", "DELETE FROM images WHERE path = '#{url}'")
    end
end

if i > 0
    system("dcop", "amarok", "playlist", "popupMessage" "Removed #{i} stale 'images' entries from the database")
end