File indexing completed on 2024-05-05 04:49:36
0001 #!/usr/bin/env ruby 0002 # 0003 # script to remove stale images in the database 0004 # 0005 # (c) 2006 Roland Gigler <rolandg@web.de> 0006 # License: GNU General Public License V2 0007 0008 system("dcop", "amarok", "playlist", "shortStatusMessage", "Removing stale 'images' entries from the database") 0009 0010 qresult = `dcop amarok collection query "SELECT path FROM images;"` 0011 result = qresult.split( "\n" ) 0012 0013 i = 0 0014 0015 result.each do |url| 0016 #puts "url: #{url}" 0017 unless FileTest.exist?( url ) 0018 i = i + 1 0019 url.gsub!(/[']/, '\\\\\'') 0020 puts "Deleting: #{url}" 0021 system("dcop", "amarok", "collection", "query", "DELETE FROM images WHERE path = '#{url}'") 0022 end 0023 end 0024 0025 if i > 0 0026 system("dcop", "amarok", "playlist", "popupMessage" "Removed #{i} stale 'images' entries from the database") 0027 end