Skip to content

Commit

Permalink
Adjusted DP rsync commands to respect dest conventions.
Browse files Browse the repository at this point in the history
Whenever transfering any files through DP apis, the destination's
prefered (default) group and setgid bits for dirs are used.
  • Loading branch information
prioux committed Sep 6, 2017
1 parent dec6295 commit 0e18cde
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions BrainPortal/app/models/data_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def cache_copy_from_local_file(userfile, localpath)
else
FileUtils.remove_entry(dest, true) if File.exists?(dest) && File.directory?(dest)
end
rsyncout = bash_this("rsync -a -l --delete #{self.rsync_excludes} #{shell_escape(localpath)}#{needslash} #{shell_escape(dest)} 2>&1")
rsyncout = bash_this("rsync -a -l --no-p --no-g --chmod=u=rwX,g=rX,o=r --delete #{self.rsync_excludes} #{shell_escape(localpath)}#{needslash} #{shell_escape(dest)} 2>&1")
cb_error "Failed to rsync local file '#{localpath}' to cache file '#{dest}';\nrsync reported: #{rsyncout}" unless rsyncout.blank?
end
sync_to_provider(userfile)
Expand Down Expand Up @@ -589,7 +589,7 @@ def cache_copy_to_local_file(userfile,localpath)
else
FileUtils.remove_entry(localpath, true) if File.exists?(localpath) && File.directory?(localpath)
end
rsyncout = bash_this("rsync -a -l --delete #{self.rsync_excludes} #{shell_escape(source)}#{needslash} #{shell_escape(localpath)} 2>&1")
rsyncout = bash_this("rsync -a -l --no-p --no-g --chmod=u=rwX,g=rX,o=r --delete #{self.rsync_excludes} #{shell_escape(source)}#{needslash} #{shell_escape(localpath)} 2>&1")
cb_error "Failed to rsync cache file '#{source}' to local file '#{localpath}';\nrsync reported: #{rsyncout}" unless rsyncout.blank?
true
end
Expand Down
4 changes: 2 additions & 2 deletions BrainPortal/app/models/ssh_data_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def impl_sync_to_cache(userfile) #:nodoc:

rsync = rsync_over_ssh_prefix
# It's IMPORTANT that the source be specified with a bare ':' in front.
text = bash_this("#{rsync} -a -l --delete #{self.rsync_excludes} :#{remote_shell_escape(remotefull)}#{sourceslash} #{shell_escape(localfull)} 2>&1")
text = bash_this("#{rsync} -a -l --no-p --no-g --chmod=u=rwX,g=rX,o=r --delete #{self.rsync_excludes} :#{remote_shell_escape(remotefull)}#{sourceslash} #{shell_escape(localfull)} 2>&1")
text.sub!(/Warning: Permanently added[^\n]+known hosts.\s*/i,"") # a common annoying warning
cb_error "Error syncing userfile to local cache, rsync returned:\n#{text}" unless text.blank?
unless File.exist?(localfull)
Expand All @@ -100,7 +100,7 @@ def impl_sync_to_provider(userfile) #:nodoc:
sourceslash = userfile.is_a?(FileCollection) ? "/" : ""
rsync = rsync_over_ssh_prefix
# It's IMPORTANT that the destination be specified with a bare ':' in front.
text = bash_this("#{rsync} -a -l --delete #{self.rsync_excludes} #{shell_escape(localfull)}#{sourceslash} :#{remote_shell_escape(remotefull)} 2>&1")
text = bash_this("#{rsync} -a -l --no-p --no-g --chmod=u=rwX,g=rX,o=r --delete #{self.rsync_excludes} #{shell_escape(localfull)}#{sourceslash} :#{remote_shell_escape(remotefull)} 2>&1")
text.sub!(/Warning: Permanently added[^\n]+known hosts.\s*/i,"") # a common annoying warning
cb_error "Error syncing userfile to data provider, rsync returned:\n#{text}" unless text.blank?
unless self.provider_file_exists?(userfile).to_s =~ /file|dir/
Expand Down

0 comments on commit 0e18cde

Please sign in to comment.