mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
Fixes for webdav directories
This commit is contained in:
parent
4195b903d7
commit
06778925e0
4 changed files with 21 additions and 2 deletions
|
@ -161,7 +161,6 @@ post '/site/create_directory' do
|
|||
require_login
|
||||
|
||||
path = "#{params[:dir] || ''}/#{params[:name]}"
|
||||
|
||||
result = current_site.create_directory path
|
||||
|
||||
if result != true
|
||||
|
|
|
@ -42,6 +42,11 @@ map '/webdav' do
|
|||
end
|
||||
end
|
||||
|
||||
if env['REQUEST_METHOD'] == 'MKCOL'
|
||||
site.create_directory env['PATH_INFO']
|
||||
return [201, {}, ['']]
|
||||
end
|
||||
|
||||
if env['REQUEST_METHOD'] == 'MOVE'
|
||||
tmpfile = Tempfile.new 'moved_file'
|
||||
tmpfile.close
|
||||
|
|
|
@ -671,7 +671,7 @@ class Site < Sequel::Model
|
|||
return 'Directory (or file) already exists.'
|
||||
end
|
||||
|
||||
path_dirs = path.to_s.split '/'
|
||||
path_dirs = path.to_s.split('/').select {|p| ![nil, '.', ''].include?(p) }
|
||||
|
||||
path_site_file = ''
|
||||
|
||||
|
@ -682,6 +682,8 @@ class Site < Sequel::Model
|
|||
path_site_file += '/' + path_dirs.shift
|
||||
end
|
||||
|
||||
raise ArgumentError, 'directory name cannot be empty' if path_site_file == ''
|
||||
|
||||
site_file = SiteFile.where(site_id: self.id, path: path_site_file).first
|
||||
|
||||
if site_file.nil?
|
||||
|
|
|
@ -5,6 +5,19 @@ def app
|
|||
end
|
||||
|
||||
describe Site do
|
||||
describe 'directory create' do
|
||||
it 'handles wacky pathnames' do
|
||||
['/derp', '/derp/'].each do |path|
|
||||
site = Fabricate :site
|
||||
site_file_count = site.site_files_dataset.count
|
||||
site.create_directory path
|
||||
site.site_files.select {|s| s.path == '' || s.path == '.'}.length.must_equal 0
|
||||
site.site_files.select {|s| s.path == path.gsub('/', '')}.first.wont_be_nil
|
||||
site.site_files_dataset.count.must_equal site_file_count+1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'custom_max_space' do
|
||||
it 'should use the custom max space if it is more' do
|
||||
site = Fabricate :site
|
||||
|
|
Loading…
Add table
Reference in a new issue