Skip to content

Commit acf4139

Browse files
committed
Use more informative variable names
1 parent e1afc82 commit acf4139

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/fpm/dependency.f90

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ subroutine get_from_registry(self, target_dir, global_settings, error, downloade
614614
!> Downloader instance.
615615
class(downloader_t), optional, intent(in) :: downloader_
616616

617-
character(:), allocatable :: cache_path, target_url, tmp_file, tmp_path
617+
character(:), allocatable :: cache_path, target_url, tmp_pkg_data_path, tmp_pkg_data_file
618618
type(version_t) :: version
619619
integer :: stat, unit
620620
type(json_object) :: json
@@ -644,17 +644,17 @@ subroutine get_from_registry(self, target_dir, global_settings, error, downloade
644644
end if
645645

646646
! Define location of the temporary folder and file.
647-
tmp_path = join_path(global_settings%path_to_config_folder, 'tmp')
648-
tmp_file = join_path(tmp_path, 'package_data.tmp')
649-
if (.not. exists(tmp_path)) call mkdir(tmp_path)
650-
open (newunit=unit, file=tmp_file, action='readwrite', iostat=stat)
647+
tmp_pkg_data_path = join_path(global_settings%path_to_config_folder, 'tmp')
648+
tmp_pkg_data_file = join_path(tmp_pkg_data_path, 'package_data.tmp')
649+
if (.not. exists(tmp_pkg_data_path)) call mkdir(tmp_pkg_data_path)
650+
open (newunit=unit, file=tmp_pkg_data_file, action='readwrite', iostat=stat)
651651
if (stat /= 0) then
652652
call fatal_error(error, "Error creating temporary file for downloading package '"//self%name//"'."); return
653653
end if
654654

655655
! Include namespace and package name in the target url and download package data.
656656
target_url = global_settings%registry_settings%url//'/packages/'//self%namespace//'/'//self%name
657-
call downloader%get_pkg_data(target_url, self%requested_version, tmp_file, json, error)
657+
call downloader%get_pkg_data(target_url, self%requested_version, tmp_pkg_data_file, json, error)
658658
close (unit, status='delete')
659659
if (allocated(error)) return
660660

@@ -663,7 +663,7 @@ subroutine get_from_registry(self, target_dir, global_settings, error, downloade
663663
if (allocated(error)) return
664664

665665
! Open new tmp file for downloading the actual package.
666-
open (newunit=unit, file=tmp_file, action='readwrite', iostat=stat)
666+
open (newunit=unit, file=tmp_pkg_data_file, action='readwrite', iostat=stat)
667667
if (stat /= 0) then
668668
call fatal_error(error, "Error creating temporary file for downloading package '"//self%name//"'."); return
669669
end if
@@ -675,13 +675,13 @@ subroutine get_from_registry(self, target_dir, global_settings, error, downloade
675675
call mkdir(cache_path)
676676

677677
print *, "Downloading '"//join_path(self%namespace, self%name, version%s())//"' ..."
678-
call downloader%get_file(target_url, tmp_file, error)
678+
call downloader%get_file(target_url, tmp_pkg_data_file, error)
679679
if (allocated(error)) then
680680
close (unit, status='delete'); return
681681
end if
682682

683683
! Unpack the downloaded package to the final location.
684-
call downloader%unpack(tmp_file, cache_path, error)
684+
call downloader%unpack(tmp_pkg_data_file, cache_path, error)
685685
close (unit, status='delete')
686686
if (allocated(error)) return
687687
end if

src/fpm/downloader.f90

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ module fpm_downloader
1818
contains
1919

2020
!> Perform an http get request and save output to file.
21-
subroutine get_pkg_data(url, version, tmp_file, json, error)
21+
subroutine get_pkg_data(url, version, tmp_pkg_data_file, json, error)
2222
character(*), intent(in) :: url
2323
type(version_t), allocatable, intent(in) :: version
24-
character(*), intent(in) :: tmp_file
24+
character(*), intent(in) :: tmp_pkg_data_file
2525
type(json_object), intent(out) :: json
2626
type(error_t), allocatable, intent(out) :: error
2727

@@ -31,14 +31,14 @@ subroutine get_pkg_data(url, version, tmp_file, json, error)
3131

3232
if (allocated(version)) then
3333
! Request specific version.
34-
call get_file(url//'/'//version%s(), tmp_file, error)
34+
call get_file(url//'/'//version%s(), tmp_pkg_data_file, error)
3535
else
3636
! Request latest version.
37-
call get_file(url, tmp_file, error)
37+
call get_file(url, tmp_pkg_data_file, error)
3838
end if
3939
if (allocated(error)) return
4040

41-
call json_load(j_value, tmp_file, error=j_error)
41+
call json_load(j_value, tmp_pkg_data_file, error=j_error)
4242
if (allocated(j_error)) then
4343
allocate (error); call move_alloc(j_error%message, error%message); call json%destroy(); return
4444
end if
@@ -51,19 +51,19 @@ subroutine get_pkg_data(url, version, tmp_file, json, error)
5151
json = ptr
5252
end
5353

54-
subroutine get_file(url, tmp_file, error)
54+
subroutine get_file(url, tmp_pkg_data_file, error)
5555
character(*), intent(in) :: url
56-
character(*), intent(in) :: tmp_file
56+
character(*), intent(in) :: tmp_pkg_data_file
5757
type(error_t), allocatable, intent(out) :: error
5858

5959
integer :: stat
6060

6161
if (which('curl') /= '') then
6262
print *, "Downloading package data from '"//url//"' ..."
63-
call execute_command_line('curl '//url//' -s -o '//tmp_file, exitstat=stat)
63+
call execute_command_line('curl '//url//' -s -o '//tmp_pkg_data_file, exitstat=stat)
6464
else if (which('wget') /= '') then
6565
print *, "Downloading package data from '"//url//"' ..."
66-
call execute_command_line('wget '//url//' -q -O '//tmp_file, exitstat=stat)
66+
call execute_command_line('wget '//url//' -q -O '//tmp_pkg_data_file, exitstat=stat)
6767
else
6868
call fatal_error(error, "Neither 'curl' nor 'wget' installed."); return
6969
end if

0 commit comments

Comments
 (0)