kadyb / rgugik

Download datasets from Polish Head Office of Geodesy and Cartography
https://kadyb.github.io/rgugik/
Other
33 stars 4 forks source link

Implement SHA-1 checking in 'orto_download' #1

Closed kadyb closed 4 years ago

kadyb commented 4 years ago

It should be optional.

library("sf")
polygon = read_sf("poligon.gpkg")
req_df = orto_request(polygon)
orto_download(req_df[1:2, ])

as.character(openssl::sha1(file("43_67170_N-34-139-A-c-1-2.tif")))
#> "df6ffeb93225bf578085b52c96e3bc78df129e7d"
req_df[1, "sha1"]
#> "df6ffeb93225bf578085b52c96e3bc78df129e7d"

as.character(openssl::sha1(file("69755_140758_N-34-139-A-c-1-2.tif")))
#> "7fdee9eb8750f4ce12b54901d7f1703598fa115b"
req_df[2, "sha1"]
#> "7fdee9eb8750f4ce12b54901d7f1703598fa115b"

Does the connection to the file need to be closed?

kadyb commented 4 years ago

@Nowosad, can you confirm that in this case the connection to file is closed automatically?

name_file = "test.tiff" 
tmp_SHA = as.character(openssl::sha1(file(name_file)))
kadyb commented 4 years ago

Add in b931b6b

library("sf")
polygon = read_sf("test.gpkg")
req_df = orto_request(polygon = polygon)
orto_download(req_df[1, ])
as.character(openssl::sha1(file("43_67170_N-34-139-A-c-1-2.tif"))) == req_df[1, "sha1"]
#> TRUE

req_df_false = req_df
req_df_false[1, "sha1"] = "XXX"
orto_download(req_df_false[1, ], check_SHA = TRUE, quiet = TRUE)
#> Warning in orto_download(req_df2[1:2, ], check_SHA = TRUE, quiet = TRUE) :
#> 43_67170_N-34-139-A-c-1-2.tif incorrect SHA