X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/d8fc1ec5f984b7ab6a7886e054c9dd272d3678b1..200f486870c88f3916ede7bcb36b47b374a63901:/cookbooks/tile/templates/default/expire-tiles.erb?ds=sidebyside diff --git a/cookbooks/tile/templates/default/expire-tiles.erb b/cookbooks/tile/templates/default/expire-tiles.erb index 2c0e7406e..b3a790f6a 100644 --- a/cookbooks/tile/templates/default/expire-tiles.erb +++ b/cookbooks/tile/templates/default/expire-tiles.erb @@ -2,16 +2,53 @@ # DO NOT EDIT - This file is being maintained by Chef -require 'expire' +require "fileutils" -tile_dirs = [ -<% node[:tile][:styles].each do |name,details| -%> +tileDirs = [ +<% node[:tile][:styles].each_key do |name| -%> "/srv/tile.openstreetmap.org/tiles/<%= name %>", <% end -%> ] -max_zoom = <%= node[:tile][:styles].collect { |n,d| d[:max_zoom] }.max %> +tilesExpired = 0 +tilesIgnored = 0 -ARGV.each do |f| - Expire::expire(f, 13, max_zoom, tile_dirs) +expiredTime = Time.new(2000, 1, 1) + +Dir.glob("/var/lib/replicate/expire-queue/changes-*.txt").sort.each do |f| + File.open(f, "r") do |file| + file.each do |line| + z, x, y = line.split("/") + + z = z.to_i + 3 + x = x.to_i * 8 + y = y.to_i * 8 + + hash = [] + + 1.upto(5) do + hash.push(((x & 0xf) << 4) | (y & 0xf)) + + x = x >> 4 + y = y >> 4 + end + + tileName = "#{z}/#{hash[4]}/#{hash[3]}/#{hash[2]}/#{hash[1]}/#{hash[0]}.meta" + + tileDirs.each do |tileDir| + if File.exist?("#{tileDir}/#{tileName}") + FileUtils.touch("#{tileDir}/#{tileName}", :mtime => expiredTime) + + tilesExpired = tilesExpired + 1 + else + tilesIgnored = tilesIgnored + 1 + end + end + end + end + + File::unlink(f) end + +puts "Meta tiles expired: #{tilesExpired}" +puts "Meta tiles not present: #{tilesIgnored}"