retrieve_build_artifacts Subroutine

public subroutine retrieve_build_artifacts(hash_key, target_dir, success)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: hash_key

Retrieve cached build artifacts

character(len=*), intent(in) :: target_dir

Retrieve cached build artifacts

logical, intent(out) :: success

Source Code

    subroutine retrieve_build_artifacts(hash_key, target_dir, success)
        !> Retrieve cached build artifacts
        character(len=*), intent(in) :: hash_key, target_dir
        logical, intent(out) :: success
        character(len=:), allocatable :: cache_path, command
        integer :: exitstat

        ! Check if cache exists
        cache_path = join_path(trim(get_cache_subdir('builds')), trim(hash_key))
        if (.not. exists(trim(cache_path))) then
            success = .false.
            return
        end if

        ! Create target directory
        call ensure_cache_dir(target_dir, success)
        if (.not. success) return

        ! Copy cached artifacts to target using cross-platform commands
        if (get_os_type() == OS_WINDOWS) then
            command = 'xcopy /E /I /Y "'//trim(escape_shell_arg(cache_path))//'" "'// &
                      trim(escape_shell_arg(target_dir))//'" >nul 2>&1'
        else
            command = 'cp -r "'//trim(escape_shell_arg(cache_path))//'/." "'// &
                      trim(escape_shell_arg(target_dir))//'/" >/dev/null 2>&1'
        end if

        call run(command, exitstat=exitstat)
        success = (exitstat == 0)

    end subroutine retrieve_build_artifacts