Bugfix:5033349
Dongwon Kang [Wed, 20 Jul 2011 08:04:42 +0000 (17:04 +0900)]
- Checking download data dir instread of /cache.
- Trying to remove stale files regardless of the low space thereshold.
(Note: This bug happens when download dir size is 100mb and there is a
file > 100mb in /cache.)

Change-Id: Iacded74eaadb2aa7f0af8d1b7e0f922e81c7e07c

src/com/android/providers/downloads/StorageManager.java

index 228f668..2766860 100644 (file)
@@ -222,16 +222,17 @@ class StorageManager {
         }
         if (root.equals(mDownloadDataDir)) {
             // this download is going into downloads data dir. check space in that specific dir.
-            bytesAvailable = getAvailableBytesInDownloadsDataDir(mSystemCacheDir);
+            bytesAvailable = getAvailableBytesInDownloadsDataDir(mDownloadDataDir);
             if (bytesAvailable < sDownloadDataDirLowSpaceThreshold) {
                 // print a warning
                 Log.w(Constants.TAG, "Downloads data dir: " + root +
-                        " is running low on space. space available (in b): " + bytesAvailable);
-            } else if (bytesAvailable < targetBytes) {
+                        " is running low on space. space available (in bytes): " + bytesAvailable);
+            }
+            if (bytesAvailable < targetBytes) {
                 // Insufficient space; make space.
                 discardPurgeableFiles(destination, sDownloadDataDirLowSpaceThreshold);
                 removeSpuriousFiles();
-                bytesAvailable = getAvailableBytesInDownloadsDataDir(mSystemCacheDir);
+                bytesAvailable = getAvailableBytesInDownloadsDataDir(mDownloadDataDir);
             }
         }
         if (bytesAvailable < targetBytes) {