mirror of
https://github.com/neocities/neocities.git
synced 2025-08-06 09:34:57 +02:00
remove surf code, clean up purge cache and better define purge cache tests for expected behavior
This commit is contained in:
parent
b4caf44af4
commit
29619d51ee
12 changed files with 106 additions and 395 deletions
|
@ -766,18 +766,24 @@ class Site < Sequel::Model
|
|||
def purge_cache(path)
|
||||
relative_path = path.gsub base_files_path, ''
|
||||
|
||||
# We gotta flush the dirname too if it's an index file.
|
||||
if relative_path != '' && relative_path.match(/\/$|index\.html?$/i)
|
||||
PurgeCacheWorker.perform_async username, relative_path
|
||||
if relative_path[0] != '/'
|
||||
relative_path = '/' + relative_path
|
||||
end
|
||||
|
||||
# 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
|
||||
purge_file_path = '' if purge_file_path == '.'
|
||||
purge_file_path += '/' if purge_file_path != '/'
|
||||
|
||||
PurgeCacheWorker.perform_async username, '/?surf=1' if purge_file_path == '/'
|
||||
PurgeCacheWorker.perform_async username, purge_file_path
|
||||
else
|
||||
PurgeCacheWorker.perform_async username, relative_path
|
||||
html = relative_path.match(/(.*)\.html?$/)
|
||||
if html
|
||||
PurgeCacheWorker.perform_async username, html.captures.first
|
||||
else
|
||||
PurgeCacheWorker.perform_async username, relative_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -104,8 +104,6 @@ class SiteFile < Sequel::Model
|
|||
DB.transaction do
|
||||
self.path = new_path
|
||||
self.save_changes
|
||||
site.purge_cache current_path
|
||||
site.purge_cache new_path
|
||||
|
||||
if is_directory
|
||||
site_files_in_dir = site.site_files.select {|sf| sf.path =~ /^#{current_path}\//}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue