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

fix: ignore subdirs in the dropbox watch agent #3210

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/models/agents/dropbox_watch_agent.rb
Expand Up @@ -52,7 +52,9 @@ def check
private

def ls(dir_to_watch)
dropbox.ls(dir_to_watch).map { |file| { 'path' => file.path, 'rev' => file.rev, 'modified' => file.server_modified } }
dropbox.ls(dir_to_watch)
.select { |entry| entry.respond_to?(:rev) }
.map { |file| { 'path' => file.path, 'rev' => file.rev, 'modified' => file.server_modified } }
end

def previous_contents
Expand Down
20 changes: 18 additions & 2 deletions spec/models/agents/dropbox_watch_agent_spec.rb
Expand Up @@ -50,7 +50,15 @@

describe '#check' do

let(:first_result) { Dropbox::API::Object.convert([{ 'path_display' => '1.json', 'rev' => '1', 'server_modified' => '01-01-01' }], nil) }
let(:first_result) do
Dropbox::API::Object.convert(
[
{ 'path_display' => '1.json', 'rev' => '1', 'server_modified' => '01-01-01' },
{ 'path_display' => 'sub_dir_1', '.tag' => 'folder' }
],
nil
)
end

before(:each) do
allow(Dropbox::API::Client).to receive(:new) do
Expand All @@ -77,7 +85,15 @@

context 'subsequent calls' do

let(:second_result) { Dropbox::API::Object.convert([{ 'path_display' => '2.json', 'rev' => '1', 'server_modified' => '02-02-02' }], nil) }
let(:second_result) do
Dropbox::API::Object.convert(
[
{ 'path_display' => '2.json', 'rev' => '1', 'server_modified' => '02-02-02' },
{ 'path_display' => 'sub_dir_2', '.tag' => 'folder' }
],
nil
)
end

before(:each) do
@agent.memory = { 'contents' => 'not_empty' }
Expand Down