From 601cb3a3aaa183cfc4f2a1a934cb50e36a98ba5b Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Tue, 15 Apr 2025 10:07:39 +0200 Subject: [PATCH] fix: create tmp dir for pin checkout in final folder (#1936) --- src/alire/alire-user_pins.adb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/alire/alire-user_pins.adb b/src/alire/alire-user_pins.adb index 4953065c..682f8243 100644 --- a/src/alire/alire-user_pins.adb +++ b/src/alire/alire-user_pins.adb @@ -160,7 +160,14 @@ package body Alire.User_Pins is Commit : String := "") is package Adirs renames Ada.Directories; - Temp : Directories.Temp_File; + use Directories.Operators; + + -- Ensure the temporary pin location is in the same directory as the + -- final one, so a plain rename should always succeed. + Temp : Directories.Temp_File := + Directories.With_Name + (Adirs.Containing_Directory (Destination) + / Directories.Temp_Name); begin -- Skip checkout of existing commit @@ -170,6 +177,12 @@ package body Alire.User_Pins is return; end if; + -- Create parent for a first pin + + if not Adirs.Exists (Adirs.Containing_Directory (Destination)) then + Adirs.Create_Path (Adirs.Containing_Directory (Destination)); + end if; + -- Check out the branch or commit Put_Info ("Deploying " & Utils.TTY.Name (Crate) @@ -195,9 +208,6 @@ package body Alire.User_Pins is -- Successful checkout - if not Adirs.Exists (Adirs.Containing_Directory (Destination)) then - Adirs.Create_Path (Adirs.Containing_Directory (Destination)); - end if; Adirs.Rename (Temp.Filename, Destination); Temp.Keep; end Checkout; -- 2.39.5