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:
micio 2013-08-06 21:15:51 +00:00
parent bb65e25c90
commit 1cd2a51a13

View file

@ -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%