Skip to content

Commit

Permalink
Don't try to obtain the parent dir of '/' in tmp cleanup (#1609)
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo authored Mar 4, 2024
1 parent 74196da commit a65f036
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/alire/alire-directories.adb
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 =>
Expand Down

0 comments on commit a65f036

Please sign in to comment.