зеркало из https://github.com/mozilla/gecko-dev.git
Bug 754575 - Cache.Trash* files fill up disk space r=blassey r=jduell
This commit is contained in:
Родитель
c8d931afa8
Коммит
d80b2ddb63
|
@ -331,6 +331,10 @@ public class GeckoAppShell
|
|||
File cacheFile = getCacheDir();
|
||||
GeckoAppShell.putenv("MOZ_LINKER_CACHE=" + cacheFile.getPath());
|
||||
|
||||
// setup the app-specific cache path
|
||||
f = geckoApp.getCacheDir();
|
||||
GeckoAppShell.putenv("CACHE_DIRECTORY=" + f.getPath());
|
||||
|
||||
// gingerbread introduces File.getUsableSpace(). We should use that.
|
||||
long freeSpace = getFreeSpace();
|
||||
try {
|
||||
|
|
|
@ -386,6 +386,10 @@ public class GeckoAppShell
|
|||
// Enable fixed position layers
|
||||
GeckoAppShell.putenv("MOZ_ENABLE_FIXED_POSITION_LAYERS=1");
|
||||
|
||||
// setup the app-specific cache path
|
||||
f = context.getCacheDir();
|
||||
GeckoAppShell.putenv("CACHE_DIRECTORY=" + f.getPath());
|
||||
|
||||
putLocaleEnv();
|
||||
}
|
||||
|
||||
|
|
|
@ -215,9 +215,6 @@ nsDeleteDir::DeleteDir(nsIFile *dirIn, bool moveToTrash, PRUint32 delay)
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Important: must rename directory w/o changing parent directory: else on
|
||||
// NTFS we'll wait (with cache lock) while nsIFile's ACL reset walks file
|
||||
// tree: was hanging GUI for *minutes* on large cache dirs.
|
||||
// Append random number to the trash directory and check if it exists.
|
||||
srand(PR_Now());
|
||||
nsCAutoString leaf;
|
||||
|
@ -240,7 +237,18 @@ nsDeleteDir::DeleteDir(nsIFile *dirIn, bool moveToTrash, PRUint32 delay)
|
|||
if (!leaf.Length())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
nsCOMPtr<nsIFile> parent;
|
||||
rv = trash->GetParent(getter_AddRefs(parent));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = dir->MoveToNative(parent, leaf);
|
||||
#else
|
||||
// Important: must rename directory w/o changing parent directory: else on
|
||||
// NTFS we'll wait (with cache lock) while nsIFile's ACL reset walks file
|
||||
// tree: was hanging GUI for *minutes* on large cache dirs.
|
||||
rv = dir->MoveToNative(nsnull, leaf);
|
||||
#endif
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
} else {
|
||||
|
@ -262,7 +270,25 @@ nsDeleteDir::DeleteDir(nsIFile *dirIn, bool moveToTrash, PRUint32 delay)
|
|||
nsresult
|
||||
nsDeleteDir::GetTrashDir(nsIFile *target, nsCOMPtr<nsIFile> *result)
|
||||
{
|
||||
nsresult rv = target->Clone(getter_AddRefs(*result));
|
||||
nsresult rv;
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
// Try to use the app cache folder for cache trash on Android
|
||||
char* cachePath = getenv("CACHE_DIRECTORY");
|
||||
if (cachePath) {
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(cachePath),
|
||||
true, getter_AddRefs(*result));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Add a sub folder with the cache folder name
|
||||
nsCAutoString leaf;
|
||||
rv = target->GetNativeLeafName(leaf);
|
||||
(*result)->AppendNative(leaf);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
rv = target->Clone(getter_AddRefs(*result));
|
||||
}
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
@ -301,7 +327,11 @@ nsDeleteDir::RemoveOldTrashes(nsIFile *cacheDir)
|
|||
return rv;
|
||||
|
||||
nsCOMPtr<nsIFile> parent;
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
rv = trash->GetParent(getter_AddRefs(parent));
|
||||
#else
|
||||
rv = cacheDir->GetParent(getter_AddRefs(parent));
|
||||
#endif
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче