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: rename files during the transfer, adding the .partial extension #467

Open
wants to merge 2 commits into
base: transition-to-runkit
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/syskit/cli/log_runtime_archive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ def self.archive_dataset(
archive_filter_candidates_partial(candidates)
end

candidates = candidates.reject { |file| file.to_s.end_with?('.partial') }
candidates.each_with_index do |child_path, i|
add_to_archive(archive_io, child_path, logger: logger)

Expand Down
18 changes: 12 additions & 6 deletions lib/syskit/roby_app/log_transfer_server/ftp_upload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def open
# @return [LogUploadState::Result]
def open_and_transfer(root: nil)
open { |ftp| transfer(ftp, root) }

LogUploadState::Result.new(@file, true, nil)
rescue StandardError => e
LogUploadState::Result.new(@file, false, e.message)
Expand All @@ -87,13 +88,18 @@ def chdir_to_file_directory(ftp, root)
def transfer(ftp, root)
last = Time.now
chdir_to_file_directory(ftp, root) if root
File.open(@file) do |file_io|
ftp.storbinary("STOR #{File.basename(@file)}",
file_io, Net::FTP::DEFAULT_BLOCKSIZE) do |buf|
now = Time.now
rate_limit(buf.size, now, last)
last = Time.now
begin
File.open(@file) do |file_io|
ftp.storbinary("STOR #{File.basename(@file)}",
file_io, Net::FTP::DEFAULT_BLOCKSIZE) do |buf|
now = Time.now
rate_limit(buf.size, now, last)
last = Time.now
end
end
ftp.rename("#{File.basename(@file)}.partial", File.basename(@file))
rescue StandardError => e
LogUploadState::Result.new(@file, false, e.message)
end
end

Expand Down