From 46fc4a0a8e00109e3f61505575b89cde67d5040d Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 28 Feb 2017 10:44:44 +0100 Subject: [PATCH] Correctly rename g-code file once it is generated. --- lib/Slic3r/Print.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 610d4aace..12fd69431 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -101,7 +101,15 @@ sub export_gcode { # close our gcode file close $fh; - rename $tempfile, $output_file if $tempfile; + if ($tempfile) { + my $i; + for ($i = 0; $i < 5; $i += 1) { + last if (rename Slic3r::encode_path($tempfile), Slic3r::encode_path($file)); + # Wait for 1/4 seconds and try to rename once again. + select(undef, undef, undef, 0.25); + } + Slic3r::debugf "Failed to remove the output G-code file from $tempfile to $file. Is $tempfile locked?\n" if ($i == 5); + } } # run post-processing scripts