Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

capture of modules-db does not work anymore #298

Closed
peetkes opened this issue Nov 3, 2014 · 2 comments
Closed

capture of modules-db does not work anymore #298

peetkes opened this issue Nov 3, 2014 · 2 comments

Comments

@peetkes
Copy link
Contributor

peetkes commented Nov 3, 2014

I tried to capture the content of a modules-db but that one failed.
./ml test capture --modules-db=sarepta-modules
Retrieving source and REST config from sarepta-modules...
ERROR: No such file or directory @ rb_sysopen - /var/folders/hj/45wrdfss2ll8jhqyy0c2r32c24hql1/T/d20141103-65428-1kxoe0j/src/app/config/config.xqy
ERROR: ["/Users/pkester/Development/StandardNorway/capture/deploy/lib/server_config.rb:1024:in initialize'", "/Users/pkester/Development/StandardNorway/capture/deploy/lib/server_config.rb:1024:inopen'", "/Users/pkester/Development/StandardNorway/capture/deploy/lib/server_config.rb:1024:in block in save_files_to_fs'", "/Users/pkester/Development/StandardNorway/capture/deploy/lib/server_config.rb:1017:ineach'", "/Users/pkester/Development/StandardNorway/capture/deploy/lib/server_config.rb:1017:in save_files_to_fs'", "/Users/pkester/Development/StandardNorway/capture/deploy/lib/server_config.rb:946:incapture'", "deploy/lib/ml.rb:140:in `

'"]

The mentioned folder exists but is completely empty.
Talked to Geert about this and apparently the folders are not created before writing the file.
This is probably caused by this function in server_config.rb:
def save_files_to_fs(target_db, target_dir)
# Get the list of URIs. We get them in order because Ruby's Dir.mkdir
# command doesn't have a -p option (create parent).

I changed this (line 1024):
File.open("#{target_dir}#{uri}", 'wb') { |file| file.write(r.body) }
into this (thanks to Geert!)
path = "#{target_dir}#{uri}"
parentdir = File.dirname "#{target_dir}#{uri}"
FileUtils.mkdir_p(parentdir) unless File.exists?(parentdir)
File.open("#{path}", 'wb') { |file| file.write(r.body) }
and then it worked again.
Same should apply to line 1006

@paxtonhare
Copy link
Contributor

Thanks, Peter.

@grtjn grtjn added the capture label Feb 20, 2015
alencruz added a commit to alencruz/roxy that referenced this issue Mar 31, 2015
…Issue marklogic-community#298

Improved the fix for Issue marklogic-community#223 based on feedback received.
Also fixes Issue marklogic-community#298 since it protects against the error condition.
In addition some of the Capture help content was clarified to reflect the implementation.
grtjn added a commit to grtjn/roxy that referenced this issue Jul 6, 2015
@grtjn grtjn modified the milestone: 1.7.3 Jul 7, 2015
dmcassel added a commit that referenced this issue Aug 17, 2015
Fixed #298 and #452: made capturing modules more robust
@grtjn
Copy link
Contributor

grtjn commented Aug 17, 2015

Fixed in dev

@grtjn grtjn closed this as completed Aug 17, 2015
grtjn added a commit to grtjn/roxy that referenced this issue Jan 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants