Alexandre Julliard : unicode: Store downloaded data files in the cache directory.
Alexandre Julliard
julliard at winehq.org
Tue Mar 24 15:28:17 CDT 2020
Module: wine
Branch: master
Commit: ec19bbf43f6ced7c05ce7f4337a3ec8d8f013afe
URL: https://source.winehq.org/git/wine.git/?a=commit;h=ec19bbf43f6ced7c05ce7f4337a3ec8d8f013afe
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Mar 24 13:13:42 2020 +0100
unicode: Store downloaded data files in the cache directory.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
tools/make_unicode | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/tools/make_unicode b/tools/make_unicode
index 86a180259f..ec5d8eafb4 100755
--- a/tools/make_unicode
+++ b/tools/make_unicode
@@ -475,29 +475,32 @@ sub to_utf16(@)
sub open_data_file($$)
{
my ($base, $name) = @_;
- (my $dir = "data/$name") =~ s/\/[^\/]+$//;
+ my $cache = ($ENV{XDG_CACHE_HOME} || "$ENV{HOME}/.cache") . "/wine";
+ (my $dir = "$cache/$name") =~ s/\/[^\/]+$//;
+ my $suffix = ($base =~ /\/\Q$UNIVERSION\E/) ? "-$UNIVERSION" : "";
local *FILE;
if ($base =~ /.*\/([^\/]+)\.zip$/)
{
- my $zip = $1;
- unless (-f "data/$zip")
+ my $zip = "$1$suffix.zip";
+ unless (-f "$cache/$zip")
{
- mkdir "data";
+ system "mkdir", "-p", $cache;
print "Fetching $base...\n";
- !system "wget", "-q", "-O", "data/$zip", $base or die "cannot fetch $base";
+ !system "wget", "-q", "-O", "$cache/$zip", $base or die "cannot fetch $base";
}
- open FILE, "-|", "unzip", "-p", "data/$zip", $name or die "cannot extract $name from $zip";
+ open FILE, "-|", "unzip", "-p", "$cache/$zip", $name or die "cannot extract $name from $zip";
}
else
{
- unless (-f "data/$name")
+ (my $dest = "$cache/$name") =~ s/(.*)(\.[^\/.]+)$/$1$suffix$2/;
+ unless (-f $dest)
{
system "mkdir", "-p", $dir;
print "Fetching $base/$name...\n";
- !system "wget", "-q", "-O", "data/$name", "$base/$name" or die "cannot fetch $base/$name";
+ !system "wget", "-q", "-O", $dest, "$base/$name" or die "cannot fetch $base/$name";
}
- open FILE, "<data/$name" or die "cannot open data/$name";
+ open FILE, "<$dest" or die "cannot open $dest";
}
return *FILE;
}
More information about the wine-cvs
mailing list