purge for delete and purge for refreshing

This commit is contained in:
Kyle Drake 2015-08-26 16:23:21 -07:00
parent 12a543d2aa
commit 985a2f8b60
7 changed files with 184 additions and 3 deletions

View file

@ -458,7 +458,7 @@ class Site < Sequel::Model
}
file_list.each do |path|
purge_cache path
delete_cache path
end
end
@ -601,6 +601,22 @@ class Site < Sequel::Model
end
end
# TODO DRY this up
def delete_cache(path)
relative_path = path.gsub base_files_path, ''
DeleteCacheOrderWorker.perform_async username, relative_path
# We gotta flush the dirname too if it's an index file.
if relative_path != '' && relative_path.match(/\/$|index\.html?$/i)
purge_file_path = Pathname(relative_path).dirname.to_s
DeleteCacheOrderWorker.perform_async username, '/?surf=1' if purge_file_path == '/'
DeleteCacheOrderWorker.perform_async username, purge_file_path
end
end
Rye::Cmd.add_command :ipfs, nil, 'add', :r
def add_to_ipfs
@ -1182,7 +1198,7 @@ class Site < Sequel::Model
rescue Errno::ENOENT
end
purge_cache path
delete_cache path
ext = File.extname(path).gsub(/^./, '')