Google Mail and counter of doom

You know Gmail. And now how marvelous service it is… A lot space for emails… And even on front page, they assure You how much space there is available Right now it says:

Lots of space

Over 2757.272164 megabytes (and counting) of free storage so you’ll never need to delete another message.

And counter goes on… Great, right? But when You check JavaScript code, it becomes interesting. There is function updateQuota. Go and read it:

function updateQuota() { 
  if (!quota) {
    return;
  }
 
  var now = (new Date()).getTime(); 
  var i;
  for (i = 0; i < CP.length; i++) {
    if (now < CP[i][0]) {
      break;
    }
  }
  if (i == 0) {
    setTimeout(updateQuota, 1000); 
  } else if (i == CP.length) {
    quota.innerHTML = CP[i - 1][1];
  } else {
    var ts = CP[i - 1][0];
    var bs = CP[i - 1][1];
    quota.innerHTML = format(((now-ts) / (CP[i][0]-ts) * (CP[i][1]-bs)) + bs); 
    setTimeout(updateQuota, 1000); 
  } 
} 

What is funny? That quota change is strictly time based function. There is no call to check real available space, it is just plain time based function. To be honest it is limited, when time reach CP[CP.length][0] it will stop ticking.

I do believe, that values are chosen very carefully, and in any given time quota value have its roots in reality. However on first glance You may think “Geeee Google is faking quote data”, when You realize there is no connection to check real quota.

Issue was brought to my attention by Tomek

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.