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

uses shutil.move instead of copy and unlink #960

Merged
merged 2 commits into from
Jul 17, 2024
Merged
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
11 changes: 5 additions & 6 deletions barman/clients/walrestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def main(args=None):
return # never reached

# If the file is present in SPOOL_DIR use it and terminate
try_deliver_from_spool(config, dest_file)
try_deliver_from_spool(config, dest_file.name)

# If required load the list of files to download in parallel
additional_files = peek_additional_files(config)
Expand Down Expand Up @@ -241,21 +241,20 @@ def try_deliver_from_spool(config, dest_file):
return otherwise.

:param argparse.Namespace config: the configuration from command line
:param dest_file: The destination file object
:param dest_file: The path to the destination file
"""
spool_file = os.path.join(config.spool_dir, config.wal_name)
spool_file = str(os.path.join(config.spool_dir, config.wal_name))
toydarian marked this conversation as resolved.
Show resolved Hide resolved

# id the file is not present, give up
if not os.path.exists(spool_file):
return

try:
shutil.copyfileobj(open(spool_file, "rb"), dest_file)
os.unlink(spool_file)
shutil.move(spool_file, dest_file)
toydarian marked this conversation as resolved.
Show resolved Hide resolved
sys.exit(0)
except IOError as e:
exit_with_error(
"Failure copying %s to %s: %s" % (spool_file, dest_file.name, e)
"Failure moving %s to %s: %s" % (spool_file, dest_file, e)
)


Expand Down
Loading