]> git.openstreetmap.org Git - chef.git/commitdiff
Fix tile expiry to use the correct paths
authorTom Hughes <tom@compton.nu>
Fri, 21 Jun 2013 21:57:26 +0000 (22:57 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 21 Jun 2013 21:57:26 +0000 (22:57 +0100)
cookbooks/tile/files/default/ruby/expire.rb
cookbooks/tile/templates/default/expire-tiles.erb

index 1c2993b714af58641a9e619e8ea7f4ce62519607..ec0a59860a24950dec66eabfb31ccf3228d0c8d7 100755 (executable)
@@ -52,7 +52,7 @@ module Expire
   end
   
   # this must match the definition of xyz_to_meta in mod_tile
-  def Expire.xyz_to_meta(root, x, y, z)
+  def Expire.xyz_to_meta(x, y, z)
     # mask off the final few bits
     x &= ~(METATILE - 1)
     y &= ~(METATILE - 1)
@@ -60,7 +60,7 @@ module Expire
     hash_path = (0..4).collect { |i| 
       (((x >> 4*i) & 0xf) << 4) | ((y >> 4*i) & 0xf) 
     }.reverse.join('/')
-    root + '/' + z.to_s + '/' + hash_path + ".meta"
+    z.to_s + '/' + hash_path + ".meta"
   end
   
   # time to reset to, some very stupidly early time, before OSM started
@@ -72,7 +72,7 @@ module Expire
     File.utime(EXPIRY_TIME, EXPIRY_TIME, meta)
   end
   
-  def Expire.expire(change_file)
+  def Expire.expire(change_file, tile_dirs)
     do_expire(change_file) do |set|
       new_set = Set.new
       meta_set = Set.new
@@ -82,8 +82,11 @@ module Expire
       set.each do |xy|
         # this has to match the routine in mod_tile
         meta = xyz_to_meta(HASH_ROOT, xy[0], xy[1], xy[2])
-        
-        meta_set.add(meta) if File.exist? meta
+
+        # check each style working out what needs expiring
+        tile_dirs.each do |tile_dir|
+          meta_set.add(tile_dir + "/" + meta) if File.exist?(tile_dir + "/" + meta)
+        end
         
         # add the parent into the set for the next round
         new_set.add([xy[0] / 2, xy[1] / 2, xy[2] - 1])
index e9473a1a7badc3b8057dd59453549887c85a07df..beea05dd95093305183a1e63901f0491289926e7 100644 (file)
@@ -4,6 +4,12 @@
 
 require 'expire'
 
+tile_dirs = [
+<% node[:tile][:styles].each do |name,details| -%>
+  "/srv/tile.openstreetmap.org/tiles/<%= name %>",
+<% end -%>
+];
+
 ARGV.each do |f|
-   Expire::expire(f)
+   Expire::expire(f, tile_dirs)
 end