|
1 | 1 | module AzStorage |
2 | 2 |
|
3 | | -using AbstractStorage, AzSessions, AzStorage_jll, Base64, DelimitedFiles, HTTP, LightXML, Serialization, Sockets |
| 3 | +using AbstractStorage, AzSessions, AzStorage_jll, Base64, Dates, DelimitedFiles, HTTP, LightXML, Serialization, Sockets |
4 | 4 |
|
5 | 5 | # https://docs.microsoft.com/en-us/rest/api/storageservices/common-rest-api-error-codes |
6 | 6 | const RETRYABLE_HTTP_ERRORS = [ |
@@ -244,7 +244,8 @@ function writebytes(c::AzContainer, o::AbstractString, data::DenseArray{UInt8}; |
244 | 244 | end |
245 | 245 |
|
246 | 246 | function writebytes_block(c, o, data, _nblocks) |
247 | | - t = token(c.session) |
| 247 | + # heuristic to increase probability that token is valid during the retry logic in AzSessions.c |
| 248 | + t = token(c.session; offset=Minute(30)) |
248 | 249 | l = ceil(Int, log10(_nblocks)) |
249 | 250 | blockids = [base64encode(lpad(blockid-1, l, '0')) for blockid in 1:_nblocks] |
250 | 251 | _blockids = [HTTP.escapeuri(blockid) for blockid in blockids] |
@@ -412,7 +413,8 @@ function readbytes!(c::AzContainer, o::AbstractString, data::DenseArray{UInt8}; |
412 | 413 | end |
413 | 414 |
|
414 | 415 | function readbytes_threaded!(c, o, data, offset, _nthreads) |
415 | | - t = token(c.session) |
| 416 | + # heuristic to increase probability that token is valid during the retry logic in AzSessions.c |
| 417 | + t = token(c.session; offset=Minute(30)) |
416 | 418 | r = ccall((:curl_readbytes_retry_threaded, libAzStorage), ResponseCodes, |
417 | 419 | (Cstring, Cstring, Cstring, Cstring, Ptr{UInt8}, Csize_t, Csize_t, Cint, Cint, Cint), |
418 | 420 | t, c.storageaccount, c.containername, addprefix(c,o), data, offset, length(data), _nthreads, c.nretry, c.verbose) |
|
0 commit comments