I'm implementing server-side git hooks for use in GitLab under Docker where Java is not available (at least that I can see). The hooks load or delete files from databases in BaseX.
I'm trying to implement the hooks in Ruby (which is much more pleasant than bash scripting in any case) and I'm using the BaseXClient.rb from https://github.com/BaseXdb/basex/tree/master/basex-api/src/main/ruby I need to create or replace files by sending the bytes--I'd rather not read the input file into a Ruby string and send that since I don't trust Ruby to not hose up the data (even when it's UTF-8 I still don't trust it, but I only started using Ruby yesterday so maybe my mistrust is misplaced?). Using the AddExample.rb as guide, I'm doing this: (Earlier code to open or create database, which works). file = File.new("../../" + path, "rb") bytes = file.read file.close puts "file=/#{bytes}/" @basex.add(path, "#{bytes}") I also tried: @basex.add(path, bytes) And I get this result (I added some debugging messages to sendCmd()): ensureDatabase(): Checking database "_dfst^metadata^temp^master"... BaseXResult: Database '_dfst^metadata^temp^master' was opened in 1.53 ms. Added or modified file: "test-newname.xml" file=/<test>This is a test 20</test> / *** sendCmd(): cmd= arg=test-newname.xml input=<test>This is a test 20</test> BaseXClient.rb:110:in `sendCmd': "test-newname.xml.xml" (Line 1): Premature end of file. (RuntimeError) from commit-hooks/git/server-side/BaseXClient.rb:64:in `add' from commit-hooks/git/server-side/post-receive:80:in `block in update' from commit-hooks/git/server-side/post-receive:74:in `each' from commit-hooks/git/server-side/post-receive:74:in `update' from commit-hooks/git/server-side/post-receive:111:in `block in <main>' from commit-hooks/git/server-side/post-receive:103:in `each' from commit-hooks/git/server-side/post-receive:103:in `<main>' Eliots-MBP:hooks ekimber$ A couple of things here: Where is the extra ".xml" in the target filename coming from? What is causing the premature end of file? It feels like it's trying interpret the second argument as a filename rather than the data to be loaded. If I use basex.execute("add to #{path} #{bytes}") it works but of course I get duplicate files if I run the command twice. If I try: @basex.execute("replace #{path} #{bytes}") Then I get the same failure. So something is not right. My Docker container is running 8.4.1 beta. What am I missing? Thanks, Eliot ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com