From a65f0360b3d7410e0f015969b38ba08e0fa14f4f Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Mon, 4 Mar 2024 11:40:53 +0100 Subject: [PATCH] Don't try to obtain the parent dir of '/' in tmp cleanup (#1609) --- src/alire/alire-directories.adb | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/alire/alire-directories.adb b/src/alire/alire-directories.adb index 8deea106..fffdb9c0 100644 --- a/src/alire/alire-directories.adb +++ b/src/alire/alire-directories.adb @@ -1,5 +1,6 @@ with AAA.Directories; +with Ada.Directories.Hierarchical_File_Names; with Ada.Numerics.Discrete_Random; with Ada.Real_Time; with Ada.Unchecked_Conversion; @@ -749,11 +750,21 @@ package body Alire.Directories is -- Remove temp dir if empty to keep things tidy, and avoid modifying -- lots of tests, but only when within <>/alire/tmp - if Ada.Directories.Simple_Name (Parent (Parent (This.Filename))) = - Paths.Working_Folder_Inside_Root - then - AAA.Directories.Remove_Folder_If_Empty (Parent (This.Filename)); - end if; + begin + if not Adirs.Hierarchical_File_Names.Is_Root_Directory_Name + (Parent (This.Filename)) + and then + Adirs.Simple_Name (Parent (Parent (This.Filename))) = + Paths.Working_Folder_Inside_Root + then + AAA.Directories.Remove_Folder_If_Empty (Parent (This.Filename)); + end if; + exception + when Use_Error => + -- May be raised by Adirs.Containing_Directory + Trace.Debug ("Failed to identify location of temp file: " + & This.Filename); + end; exception when E : others => -- 2.39.5