Skip to content

Commit

Permalink
fix: favor mv instead of perl rename
Browse files Browse the repository at this point in the history
  • Loading branch information
bibendi committed Oct 26, 2015
1 parent eab870f commit 8afb13b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/sphinx/integration/helper_adapters/remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ def index(online)
@ssh.within(reindex_host) do
indexer_args << "--nohup" if online
@ssh.execute("indexer", *indexer_args, exit_status: [0, 2])
@ssh.execute("rename -f 's/\\.tmp\\./\\.new\\./' #{config.searchd_file_path}/*_core.tmp.*") if online
if online
@ssh.execute("for NAME in #{config.searchd_file_path}/*_core.tmp.*; " +
'do mv -f "${NAME}" "${NAME/\.tmp\./.new.}"; done')
end
end

files = "#{config.searchd_file_path}/*_core#{".new" if online}.*"
Expand Down
5 changes: 3 additions & 2 deletions spec/sphinx/integration/helper_adapters/remote_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
end

describe "#index" do
before { stub_sphinx_conf(config_file: "/path/sphinx.conf") }
before { stub_sphinx_conf(config_file: "/path/sphinx.conf", searchd_file_path: "/path/data") }

context "when is online" do
context "when one host" do
Expand All @@ -71,10 +71,11 @@
expect(ssh).to receive(:within).with("s1.dev").and_yield
expect(ssh).to receive(:execute).
with("indexer", "--all", "--config /path/sphinx.conf", "--rotate", "--nohup", exit_status: [0, 2])
expect(ssh).to receive(:execute).
with('for NAME in /path/data/*_core.tmp.*; do mv -f "${NAME}" "${NAME/\.tmp\./.new.}"; done')
server = double("server", opts: {port: 22}, user: "sphinx", host: "s1.dev")
expect(ssh).to receive(:without).with("s1.dev").and_yield(server)
expect(ssh).to receive(:execute).with("rsync", any_args)
expect(ssh).to receive(:execute).with(/^rename/)
expect(ssh).to receive(:execute).with("kill", /SIGHUP/)

adapter.index(true)
Expand Down

0 comments on commit 8afb13b

Please sign in to comment.