Skip to content

Commit

Permalink
platforms: use $XDG_DATA_HOME for cache on linux/freebsd/macos
Browse files Browse the repository at this point in the history
$XDG_CACHE_HOME may be, in both specification and application,
mounted on a tmpfs, removed frequently, &c. It generally appears
to be used for small amounts of unimportant data, which is not what
Alire expects of it. This commit switches things over to
$XDG_DATA_HOME, which is generally more reliable.

Fixes #1502.
  • Loading branch information
atalii committed Dec 2, 2023
1 parent 9864809 commit 6221526
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/alire/alire-platforms-common.ads
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ private package Alire.Platforms.Common is
Default => ".")));

----------------------
-- XDG_Cache_Folder --
-- XDG_Data_Folder --
----------------------

function XDG_Cache_Folder return String
function XDG_Data_Folder return String
is (OS_Lib.Getenv
("XDG_CACHE_HOME",
Default => Unix_Home_Folder / ".cache")
("XDG_DATA_HOME",
Default => Unix_Home_Folder / ".local" / "share")
/ "alire");

-----------------------
Expand Down
10 changes: 7 additions & 3 deletions src/alire/alire-platforms-folders.ads
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ package Alire.Platforms.Folders is

function Cache return Absolute_Path;
-- Folder for dependencies, global toolchains, and any other info that is
-- not critical to lose. Can be deleted freely, it's repopulated on-demand.
-- On Linux/macOS it is ${XDG_CACHE_HOME:-$HOME/.cache}/alire
-- On Windows it is $UserProfile\.cache\alire
-- not critical to lose. Can be deleted freely, it's repopulated on-demand,
-- though is generally expected to be persistent. On Linux/macOS it is
-- ${XDG_DATA_HOME:-$HOME/.local/share}/alire. On Windows it is
-- $UserProfile\.cache\alire.
--
-- For Linux/macOS, $XDG_CACHE_HOME is intentionally not used, as some
-- distributions reccommend mounting it as a tmpfs. See #1502.

function Home return Absolute_Path;
-- $HOME (Linux/macOS) or $UserProfile (Windows)
Expand Down
2 changes: 1 addition & 1 deletion src/alire/os_freebsd/alire-platforms-folders__freebsd.adb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package body Alire.Platforms.Folders is
-- Cache --
-----------

function Cache return Absolute_Path is (Common.XDG_Cache_Folder);
function Cache return Absolute_Path is (Common.XDG_Data_Folder);

-----------
-- Config--
Expand Down
2 changes: 1 addition & 1 deletion src/alire/os_linux/alire-platforms-folders__linux.adb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package body Alire.Platforms.Folders is
-- Cache --
-----------

function Cache return Absolute_Path is (Common.XDG_Cache_Folder);
function Cache return Absolute_Path is (Common.XDG_Data_Folder);

-----------
-- Config--
Expand Down
2 changes: 1 addition & 1 deletion src/alire/os_macos/alire-platforms-folders__macos.adb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package body Alire.Platforms.Folders is
-- Cache --
-----------

function Cache return Absolute_Path is (Common.XDG_Cache_Folder);
function Cache return Absolute_Path is (Common.XDG_Data_Folder);

-----------
-- Config--
Expand Down

0 comments on commit 6221526

Please sign in to comment.