mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
dont set site changed unless /index.html is changed
This commit is contained in:
parent
b246eefe1d
commit
a732cfda88
2 changed files with 22 additions and 2 deletions
|
@ -1205,9 +1205,15 @@ class Site < Sequel::Model
|
|||
end
|
||||
|
||||
if results.include? true && opts[:new_install] != true
|
||||
if files.select {|f| f[:filename] =~ /^\/?index.html$/}.length > 0 || site_changed == true
|
||||
index_changed = true
|
||||
else
|
||||
index_changed = false
|
||||
end
|
||||
|
||||
time = Time.now
|
||||
sql = DB["update sites set site_changed=?, site_updated_at=?, updated_at=?, changed_count=changed_count+1, space_used=space_used#{new_size < 0 ? new_size.to_s : '+'+new_size.to_s} where id=?",
|
||||
true,
|
||||
index_changed,
|
||||
time,
|
||||
time,
|
||||
self.id
|
||||
|
|
|
@ -185,7 +185,7 @@ describe 'site_files' do
|
|||
File.exists?(@site.thumbnail_path('test.jpg', resolution)).must_equal true
|
||||
end
|
||||
|
||||
@site.site_changed.must_equal true
|
||||
@site.site_changed.must_equal false
|
||||
end
|
||||
|
||||
it 'fails with unsupported file' do
|
||||
|
@ -248,6 +248,20 @@ describe 'site_files' do
|
|||
end
|
||||
end
|
||||
|
||||
it 'does not register site changing until root index.html is changed' do
|
||||
upload(
|
||||
'dir' => 'derpie/derptest',
|
||||
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||
)
|
||||
@site.reload.site_changed.must_equal false
|
||||
|
||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/index.html', 'text/html')
|
||||
@site.reload.site_changed.must_equal true
|
||||
|
||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/chunkfive.otf', 'application/vnd.ms-opentype')
|
||||
@site.reload.site_changed.must_equal true
|
||||
end
|
||||
|
||||
it 'does not store new file if hash matches' do
|
||||
upload(
|
||||
'dir' => 'derpie/derptest',
|
||||
|
|
Loading…
Add table
Reference in a new issue