mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-16 14:16:09 -06:00
Examples/SkylarkUpload : avoid unneeded session savings during progress callback
git-svn-id: svn://ultimatepp.org/upp/trunk@6233 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
bb65e25c90
commit
1cd2a51a13
1 changed files with 9 additions and 8 deletions
|
|
@ -24,10 +24,15 @@ int ProgressHandler(int reason, Http &http, int size)
|
|||
// reading contents ?
|
||||
case PROGRESS_CONTENT:
|
||||
{
|
||||
int oldPercent = http[currentId];
|
||||
int total = http[totalId];
|
||||
|
||||
// take care to NOT return 100% up to upload ended really
|
||||
int percent = min(99, (int)(100.0 * size / total));
|
||||
|
||||
// avoid unnnedded session storing
|
||||
int oldCurrent = http[currentId];
|
||||
if(oldCurrent != size)
|
||||
http.SessionSet(currentId, size);
|
||||
if(oldPercent != percent)
|
||||
http.SessionSet(currentId, percent);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -47,12 +52,8 @@ int ProgressHandler(int reason, Http &http, int size)
|
|||
if(!IsNull(total))
|
||||
{
|
||||
if(total)
|
||||
{
|
||||
// if upload not ended, return the progress %
|
||||
// take care to NOT return 100% up to upload ended really
|
||||
int current = http[currentId];
|
||||
return min(99, (int)(100.0 * current / total));
|
||||
}
|
||||
return http[currentId];
|
||||
else
|
||||
{
|
||||
// upload ended, nullify session variables and return 100%
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue