invalidate_cache Subroutine

public subroutine invalidate_cache(hash_key, success)

Arguments

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

Remove cache entry

logical, intent(out) :: success

Source Code

    subroutine invalidate_cache(hash_key, success)
        !> Remove cache entry
        character(len=*), intent(in) :: hash_key
        logical, intent(out) :: success
        character(len=:), allocatable :: cache_path, command
        integer :: exitstat

        cache_path = join_path(trim(get_cache_subdir('builds')), trim(hash_key))

        ! Use cross-platform directory removal commands
        if (get_os_type() == OS_WINDOWS) then
            command = 'rmdir /S /Q "'//trim(escape_shell_arg(cache_path))//'" >nul 2>&1'
        else
           command = 'rm -rf "'//trim(escape_shell_arg(cache_path))//'" >/dev/null 2>&1'
        end if

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

    end subroutine invalidate_cache