raquamaps / aquamapsdata

R package for accessing curated data from AquaMaps.org
https://raquamaps.github.io/aquamapsdata/
GNU Affero General Public License v3.0
5 stars 2 forks source link

fix download_db() to use correct unzip wrt has_pass #23

Closed bbest closed 3 years ago

bbest commented 3 years ago

Hi @mskyttner,

Thanks for this awesome R package! I noticed this minor issue when initially trying to run download_db(), per the intro vignette. It successfully downloaded https://archive.org/download/aquamapsdb/am.db.bz2 into the temp file location, but ran the wrong method rcrypt::decrypt() for has_pass to unpack it into the target :

    if (has_pass) {
      R.utils::bunzip2(filename = temp, destname = tgt)
    } else {
      rcrypt::decrypt(temp, passphrase = passphrase, output = tgt)
    } 

Output:

Download of aquamapsdb (https://archive.org/download/aquamapsdb/am.db.bz2 -> /var/folders/2r/grqvdjfn04361tzk8mh60st40000gn/T/am.db.bz2 -> /Users/bbest/Library/Application Support/aquamaps/am.db)
 [100%] Downloaded 1249240020 bytes...
... unpacking /var/folders/2r/grqvdjfn04361tzk8mh60st40000gn/T/am.db.bz2 to /Users/bbest/Library/Application Support/aquamaps/am.db
gpg: Note: '--decrypt' is not considered an option
gpg: directory '/Users/bbest/.gnupg' created
gpg: keybox '/Users/bbest/.gnupg/pubring.kbx' created
gpg: WARNING: no command supplied.  Trying to guess what you mean ...
usage: gpg [options] [filename]
done

Simply adding a negation !has_pass should fix this:

    if (!has_pass) {
      R.utils::bunzip2(filename = temp, destname = tgt)
    } else {
      rcrypt::decrypt(temp, passphrase = passphrase, output = tgt)
    } 
mskyttner commented 3 years ago

Hi @bbest thanks for spotting this! Will merge this PR once those checks have passed.

bbest commented 3 years ago

Hi @mskyttner, great! Looks like all checks have passed 😉

mskyttner commented 3 years ago

Sorry for the delay, I got pulled away by some private matters.