Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable watch to prevent race condition between threads calling site.process #320

Merged
merged 23 commits into from
Mar 15, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fd83a67
When updating a document or page, read item by itself
parkr Mar 9, 2017
1203e14
Use ensure_* helper methods and use this more robust method as a fall…
parkr Mar 9, 2017
9e7b78d
Use accurate method names; add the || for the page server back.
parkr Mar 11, 2017
efd6ede
Merge branch 'master' into prevent-race-condition-on-change
mertkahyaoglu Mar 11, 2017
4ce5082
centralize path manipulation methods in server.rb
benbalter Mar 13, 2017
c43c34e
slightly less abstraction
benbalter Mar 13, 2017
0c170bd
DRY up removing the site source
benbalter Mar 13, 2017
82aba50
move path helper methods to its own module
benbalter Mar 13, 2017
a573bb5
correct rubocop offenses;
benbalter Mar 13, 2017
87f8e2b
centralize file manipulation methods in file helper
benbalter Mar 14, 2017
9514901
autoload ALL THE THINGS!
benbalter Mar 14, 2017
2bf85ae
add some missing tests
benbalter Mar 14, 2017
3652c41
use FileHelper and PathHelper for DataFile methods
benbalter Mar 14, 2017
f4d94ab
add entries url to collection hash
benbalter Mar 14, 2017
1d5a49b
directory_path should be private
benbalter Mar 14, 2017
5a87555
actually, actually disable watch
benbalter Mar 14, 2017
e26934f
Use @ashmaroli's approach to monkey patching the build command to dis…
benbalter Mar 15, 2017
7d086f2
stop server before starting just in case
benbalter Mar 15, 2017
c8fab6c
-f, not -9
benbalter Mar 15, 2017
e1af381
Merge branch 'master' into prevent-race-condition-on-change
benbalter Mar 15, 2017
28c4f9c
revert changes to lib/jekyll/commands/serve.rb
benbalter Mar 15, 2017
1f8c8c2
test --watch with this plugin
ashmaroli Mar 15, 2017
bce59f7
Merge pull request #324 from ashmaroli/test-watch-admin
benbalter Mar 15, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/jekyll-admin/server/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class Server < Sinatra::Base
end

write_file(write_path, document_body)
updated_document = collection.docs.find { |d| d.path == write_path }
render_404 if updated_document.nil?
ensure_document
json updated_document.to_api(:include_content => true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be document now instead of updated_document.

end

Expand Down Expand Up @@ -76,7 +75,10 @@ def relative_document_path
end

def document
collection.docs.find { |d| d.path == document_path }
collection.docs.find { |d| d.path == document_path } ||
Jekyll::Document.new(write_path, {
:collection => collection, :site => site,
}).tap(&:read)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really 🆒 You da boss 😎

end

def directory_docs
Expand Down
7 changes: 4 additions & 3 deletions lib/jekyll-admin/server/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class Server < Sinatra::Base
end

write_file(write_path, page_body)
updated_page = pages.find { |p| p.path == write_path }
render_404 if updated_page.nil?
ensure_page
json updated_page.to_api(:include_content => true)
Copy link
Member

@mertkahyaoglu mertkahyaoglu Mar 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be page.

end

Expand Down Expand Up @@ -85,7 +84,9 @@ def relative_page_path
end

def page
site.pages.find { |p| sanitized_path(p.path) == page_path }
Jekyll::Page.new(
Copy link
Member

@mertkahyaoglu mertkahyaoglu Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed || here or is this on purpose?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could do either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think he's asking if we want to look to the existing page first then fall back to creating a new one like we do for other content types?

site, site.source, File.dirname(page_path), File.basename(page_path)
)
end

def directory_path
Expand Down
7 changes: 6 additions & 1 deletion lib/jekyll-admin/server/static_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ def static_files

def file_list_dir(path) end

# TODO: StaticFile.new needs to be taught about the collection the
# file belongs to, if it belongs to a collection.
def static_file
static_files.find { |f| f.path == static_file_path }
static_files.find { |f| f.path == static_file_path } ||
Jekyll::StaticFile.new(
site, site.source, File.dirname(static_file_path), File.basename(static_file_path)
)
end

def static_files_for_path
Expand Down