Control: tags -1 + patch

The attached git patch fixes this bug.

This only addresses the cache file, not the config file; even if the
latter should move, that seems like it should occur in a separate
change.  Personally I'd argue that the config file has quite a bit of
value; I like being able to keep it in my git-managed home directory.
But in any case, that change shouldn't go in this commit.

- Josh Triplett
>From b8b1df9ff60880f25d4847145d57f7ab990c8740 Mon Sep 17 00:00:00 2001
From: Josh Triplett <[email protected]>
Date: Sun, 18 Aug 2013 16:34:31 -0700
Subject: [PATCH] Move download cache to $XDG_CONFIG_HOME (with fallback to
 ~/.cache)

Caches should live in $XDG_CONFIG_HOME, making it easier to ignore them
in version control or backup software, and easier to find and delete
them to reclaim space.  Move aptitude's download cache to
$XDG_CONFIG_HOME, with a fallback to ~/.cache if the environment does
not contain XDG_CONFIG_HOME.
---
 src/generic/apt/apt.cc | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/generic/apt/apt.cc b/src/generic/apt/apt.cc
index d534b43..5ff970c 100644
--- a/src/generic/apt/apt.cc
+++ b/src/generic/apt/apt.cc
@@ -504,12 +504,21 @@ void apt_load_cache(OpProgress *progress_bar, bool do_initselections,
 
   LOG_TRACE(logger, "Initializing the download cache.");
   // Open the download cache.  By default, it goes in
-  // ~/.aptitude/cache; it has 512Kb of in-memory cache and 10MB of
-  // on-disk cache.
-  const char *HOME = getenv("HOME");
-  if(HOME != NULL)
+  // $XDG_CACHE_HOME/aptitude-download-cache (typically
+  // ~/.cache/aptitude-download-cache); it has 512Kb of
+  // in-memory cache and 10MB of on-disk cache.
+  std::string download_cache_file_name;
+  const char *XDG_CACHE_HOME = getenv("XDG_CACHE_HOME");
+  if(XDG_CACHE_HOME)
+    download_cache_file_name = string(XDG_CACHE_HOME) + "/aptitude-download-cache";
+  else
+    {
+      const char *HOME = getenv("HOME");
+      if(HOME)
+        download_cache_file_name = string(HOME) + "/.cache/aptitude-download-cache";
+    }
+  if(!download_cache_file_name.empty())
     {
-      std::string download_cache_file_name = string(HOME) + "/.aptitude/cache";
       const int download_cache_memory_size =
 	aptcfg->FindI(PACKAGE "::UI::DownloadCache::MemorySize", 512 * 1024);
       const int download_cache_disk_size   =
-- 
1.8.4.rc3

_______________________________________________
Aptitude-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/aptitude-devel

Reply via email to