@@ -58,7 +58,8 @@ module fpm_dependency
58
58
use , intrinsic :: iso_fortran_env, only: output_unit
59
59
use fpm_environment, only: get_os_type, OS_WINDOWS, os_is_unix
60
60
use fpm_error, only: error_t, fatal_error
61
- use fpm_filesystem, only: exists, join_path, mkdir, canon_path, windows_path, list_files, is_dir, basename, os_delete_dir
61
+ use fpm_filesystem, only: exists, join_path, mkdir, canon_path, windows_path, list_files, is_dir, basename, &
62
+ os_delete_dir, get_temp_filename
62
63
use fpm_git, only: git_target_revision, git_target_default, git_revision, operator (==)
63
64
use fpm_manifest, only: package_config_t, dependency_config_t, get_package_data
64
65
use fpm_manifest_dependency, only: manifest_has_changed
@@ -637,7 +638,7 @@ subroutine get_from_registry(self, target_dir, global_settings, error, downloade
637
638
! > Downloader instance.
638
639
class(downloader_t), optional , intent (in ) :: downloader_
639
640
640
- character (:), allocatable :: cache_path, target_url, tmp_pkg_path, tmp_pkg_file
641
+ character (:), allocatable :: cache_path, target_url, tmp_file
641
642
type (version_t) :: version
642
643
integer :: stat, unit
643
644
type (json_object) :: json
@@ -666,18 +667,15 @@ subroutine get_from_registry(self, target_dir, global_settings, error, downloade
666
667
end if
667
668
end if
668
669
669
- ! Define location of the temporary folder and file.
670
- tmp_pkg_path = join_path(global_settings% path_to_config_folder, ' tmp' )
671
- if (.not. exists(tmp_pkg_path)) call mkdir(tmp_pkg_path)
672
- tmp_pkg_file = join_path(tmp_pkg_path, ' package_data.tmp' )
673
- open (newunit= unit, file= tmp_pkg_file, action= ' readwrite' , iostat= stat)
670
+ tmp_file = get_temp_filename()
671
+ open (newunit= unit, file= tmp_file, action= ' readwrite' , iostat= stat)
674
672
if (stat /= 0 ) then
675
673
call fatal_error(error, " Error creating temporary file for downloading package '" // self% name// " '." ); return
676
674
end if
677
675
678
676
! Include namespace and package name in the target url and download package data.
679
677
target_url = global_settings% registry_settings% url// ' /packages/' // self% namespace// ' /' // self% name
680
- call downloader% get_pkg_data(target_url, self% requested_version, tmp_pkg_file , json, error)
678
+ call downloader% get_pkg_data(target_url, self% requested_version, tmp_file , json, error)
681
679
close (unit, status= ' delete' )
682
680
if (allocated (error)) return
683
681
@@ -686,7 +684,7 @@ subroutine get_from_registry(self, target_dir, global_settings, error, downloade
686
684
if (allocated (error)) return
687
685
688
686
! Open new tmp file for downloading the actual package.
689
- open (newunit= unit, file= tmp_pkg_file , action= ' readwrite' , iostat= stat)
687
+ open (newunit= unit, file= tmp_file , action= ' readwrite' , iostat= stat)
690
688
if (stat /= 0 ) then
691
689
call fatal_error(error, " Error creating temporary file for downloading package '" // self% name// " '." ); return
692
690
end if
@@ -697,13 +695,13 @@ subroutine get_from_registry(self, target_dir, global_settings, error, downloade
697
695
if (is_dir(cache_path)) call os_delete_dir(os_is_unix(), cache_path)
698
696
call mkdir(cache_path)
699
697
700
- call downloader% get_file(target_url, tmp_pkg_file , error)
698
+ call downloader% get_file(target_url, tmp_file , error)
701
699
if (allocated (error)) then
702
700
close (unit, status= ' delete' ); return
703
701
end if
704
702
705
703
! Unpack the downloaded package to the final location.
706
- call downloader% unpack (tmp_pkg_file , cache_path, error)
704
+ call downloader% unpack (tmp_file , cache_path, error)
707
705
close (unit, status= ' delete' )
708
706
if (allocated (error)) return
709
707
end if
0 commit comments