Skip to content

Commit

Permalink
-o rhv-upload: Add O_TRUNC to truncate JSON file if it exists
Browse files Browse the repository at this point in the history
Fixes: #46
Thanks: Nir Soffer
  • Loading branch information
Thorsten Bolten authored and rwmjones committed Apr 6, 2024
1 parent 5672d89 commit 089d9a2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions output/output_rhv_upload.ml
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ See also the virt-v2v-output-rhv(1) manual.");
("rhv_disk_uuids", JSON.List ids) :: json_params
in
let precheck_json = dir // "v2vprecheck.json" in
let fd = Unix.openfile precheck_json [O_WRONLY; O_CREAT] 0o600 in
let fd = Unix.openfile precheck_json [O_WRONLY; O_CREAT; O_TRUNC] 0o600 in
if Python_script.run_command ~stdout_fd:fd
precheck_script json_params [] <> 0 then
error (f_"failed server prechecks, see earlier errors");
Expand Down Expand Up @@ -395,7 +395,8 @@ See also the virt-v2v-output-rhv(1) manual.");

(* Start the transfer. *)
let transfer_json = dir // sprintf "v2vtransfer%d.json" i in
let fd = Unix.openfile transfer_json [O_WRONLY; O_CREAT] 0o600 in
let fd =
Unix.openfile transfer_json [O_WRONLY; O_CREAT; O_TRUNC] 0o600 in
if Python_script.run_command ~stdout_fd:fd
transfer_script json_params [] <> 0 then
error (f_"failed to start transfer, see earlier errors");
Expand Down

0 comments on commit 089d9a2

Please sign in to comment.