mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
purge cache for stripped .html files
This commit is contained in:
parent
1d448f8cac
commit
9bb34424ff
2 changed files with 14 additions and 0 deletions
|
@ -275,6 +275,14 @@ describe 'site_files' do
|
||||||
_(File.exists?(@site.files_path('chunkfive.otf'))).must_equal true
|
_(File.exists?(@site.files_path('chunkfive.otf'))).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'purges cache for html file with extension removed' do
|
||||||
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/notindex.html', 'text/html')
|
||||||
|
_(PurgeCacheWorker.jobs.first['args'].last).must_equal '/notindex.html'
|
||||||
|
PurgeCacheWorker.jobs.clear
|
||||||
|
PurgeCacheWorker.new.perform @site.username, '/notindex.html'
|
||||||
|
_(PurgeCacheWorker.jobs.first['args'].last).must_equal '/notindex'
|
||||||
|
end
|
||||||
|
|
||||||
it 'succeeds with index.html file' do
|
it 'succeeds with index.html file' do
|
||||||
_(@site.site_changed).must_equal false
|
_(@site.site_changed).must_equal false
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/index.html', 'text/html')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/index.html', 'text/html')
|
||||||
|
|
|
@ -14,6 +14,12 @@ class PurgeCacheWorker
|
||||||
# Must always have a forward slash
|
# Must always have a forward slash
|
||||||
path = '/' + path if path[0] != '/'
|
path = '/' + path if path[0] != '/'
|
||||||
|
|
||||||
|
# Add removed html ext if present
|
||||||
|
html = path.match(/(.*)\.html?$/)
|
||||||
|
if html
|
||||||
|
PurgeCacheWorker.perform_async username, html.captures.first
|
||||||
|
end
|
||||||
|
|
||||||
$redis_proxy.publish 'proxy', {cmd: 'purge', path: "#{username}#{path}"}.to_msgpack
|
$redis_proxy.publish 'proxy', {cmd: 'purge', path: "#{username}#{path}"}.to_msgpack
|
||||||
=begin
|
=begin
|
||||||
url = Addressable::URI.encode_component(
|
url = Addressable::URI.encode_component(
|
||||||
|
|
Loading…
Add table
Reference in a new issue