Skip to content

Commit

Permalink
Fix deployment over pre-existing dependency dir (#1542)
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo authored Jan 22, 2024
1 parent ecf4e23 commit 066a58a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/alire/alire-origins-deployers.adb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ package body Alire.Origins.Deployers is
-- as some deployers may not need one (like system packages).
Temp_Dir.Keep;
if Ada.Directories.Exists (Temp_Dir.Filename) then
-- First, remove any vestigial folder that may remain
if Ada.Directories.Exists (Folder) then
Trace.Debug ("Removing spurious pre-existing dir: " & Folder);
Directories.Force_Delete (Folder);
end if;

Trace.Debug ("Renaming into place " & TTY.URL (Temp_Dir.Filename)
& " as " & TTY.URL (Folder));
Ada.Directories.Rename (Old_Name => Temp_Dir.Filename,
Expand Down
26 changes: 26 additions & 0 deletions testsuite/tests/issues/1517/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
In certain circumstances, deploying a dependency when its folder already exists
(?) causes a failure.
"""

from glob import glob
import os
import shutil
from drivers.alr import run_alr, crate_dirname

run_alr("get", "hello")
os.chdir(glob("hello_*")[0])

# Remove contens of the libhello dependency folder. The bug only happens if the
# top-level folder is not removed, so we need to iterate over its contents.
for dirpath, dirnames, filenames in \
os.walk(f"alire/cache/dependencies/{crate_dirname('libhello')}"):
for filename in filenames:
os.remove(os.path.join(dirpath, filename))
for dirname in dirnames:
shutil.rmtree(os.path.join(dirpath, dirname))

# This should not fail after the bugfix
run_alr("build")

print("SUCCESS")
5 changes: 5 additions & 0 deletions testsuite/tests/issues/1517/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
driver: python-script
build_mode: sandboxed
indexes:
basic_index:
in_fixtures: true

0 comments on commit 066a58a

Please sign in to comment.