Skip to content

Commit

Permalink
Further fixes on download
Browse files Browse the repository at this point in the history
Fixes not writing file on FTP download - no_aria
  • Loading branch information
lbusett committed Mar 8, 2017
1 parent 1dc53a5 commit efbf1b4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions R/MODIStsp_process.R
Expand Up @@ -390,17 +390,14 @@ MODIStsp_process <- function(sel_prod, start_date, end_date ,out_folder, out_fol
" --allow-overwrite --file-allocation=none --retry-wait=2", sep="")
download <- try(system(aria_string, intern = Sys.info()["sysname"] == "Windows"))
} else {
download <- try(GET(remote_filename, authenticate(user, password),
progress(), timeout(1200)))
# try(GET(remote_filename, progress(), timeout(1200)))
#
#
download <- try(GET(remote_filename,progress(), timeout(1200)))

# dwl_method <- ifelse((capabilities("libcurl") == TRUE), "libcurl", "auto")
# download <- try(download.file(url = remote_filename, destfile = local_filename, mode = "wb",
# method = dwl_method, quiet = FALSE, cacheOK = FALSE, extra = c("-L")))
}
}

# Check for errors on download try
if (class(download) == "try-error" | !is.null(attr(download,"status"))) {
er <- 5
ce <- ce + 1
Expand All @@ -422,6 +419,9 @@ MODIStsp_process <- function(sel_prod, start_date, end_date ,out_folder, out_fol
}
} else {
er <- 0
if (use_aria == FALSE) {
writeBin(download$content, local_filename)

This comment has been minimized.

Copy link
@lbusett

lbusett Mar 8, 2017

Author Contributor

solve non writing output with ftp/noaria download

}
}
}

Expand All @@ -441,6 +441,7 @@ MODIStsp_process <- function(sel_prod, start_date, end_date ,out_folder, out_fol
}
} # end while on download tries

# Futher check on downloaded file size
local_filesize <- file.info(local_filename)$size # Find the size of the new file downloaded to allow comparison with remote
if (is.na(local_filesize)){
local_filesize <- 0
Expand Down

0 comments on commit efbf1b4

Please sign in to comment.