Skip to content

Commit

Permalink
fix: rename files during the transfer, adding the .partial extension
Browse files Browse the repository at this point in the history
  • Loading branch information
DeboraTahara committed Feb 28, 2025
1 parent 85baa6d commit 5ef851b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/syskit/cli/log_runtime_archive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,14 @@ def self.transfer_dataset(
end

transfer_results = candidates.map do |child_path|
result = transfer_file(child_path, server, root)
child_path.unlink if result.success?

child_partial_path = Pathname.new("#{child_path}.partial")
File.rename(child_path, child_partial_path)
result = transfer_file(child_partial_path, server, root)
if result.success?
child_partial_path.unlink
else
File.rename(child_partial_path, child_path)
end
result
end

Expand Down
4 changes: 3 additions & 1 deletion lib/syskit/roby_app/log_transfer_server/ftp_upload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ def chdir_to_file_directory(ftp, root)
def transfer(ftp, root)
last = Time.now
chdir_to_file_directory(ftp, root) if root
partial_file = @file
renamed_file = partial_file.basename.to_s.sub(/\.partial$/, "")
File.open(@file) do |file_io|
ftp.storbinary("STOR #{File.basename(@file)}",
ftp.storbinary("STOR #{renamed_file}",
file_io, Net::FTP::DEFAULT_BLOCKSIZE) do |buf|
now = Time.now
rate_limit(buf.size, now, last)
Expand Down

0 comments on commit 5ef851b

Please sign in to comment.