[devscripts] 01/02: bts: Use make_path to create the cache directory

James McCoy jamessan at debian.org
Sat Dec 19 15:02:19 UTC 2015


This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch master
in repository devscripts.

commit 8b013f0e1c39f1e944ab3c98415364d76108cea1
Author: James McCoy <jamessan at debian.org>
Date:   Sat Dec 19 09:30:42 2015 -0500

    bts: Use make_path to create the cache directory
    
    Instead of manually ensuring each parent directory is present, just rely
    on make_path to handle it.
    
    Closes: #808394
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog |  3 +++
 scripts/bts.pl   | 14 +++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index a5ec5e2..ea84809 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -117,6 +117,9 @@ devscripts (2.15.10) UNRELEASED; urgency=medium
   * debcommit:
     + When a VCS requires a mangled package version for the tag name, still
       use the actual package version in the tag message.  (Closes: #802503)
+  * bts:
+    + Fix creation of cache dir when $XDG_CACHE_HOME doesn't exist yet.
+      (Closes: #808394)
 
   [ Daniel Kahn Gillmor ]
   * debuild:
diff --git a/scripts/bts.pl b/scripts/bts.pl
index 1ba9fc2..80f6bba 100755
--- a/scripts/bts.pl
+++ b/scripts/bts.pl
@@ -47,7 +47,7 @@ use strict;
 use warnings;
 use File::Basename;
 use File::Copy;
-use File::Path qw(mkpath make_path rmtree);
+use File::Path qw(make_path rmtree);
 use File::Spec;
 use File::Temp qw/tempfile/;
 use Net::SMTP;
@@ -2207,12 +2207,12 @@ sub bts_cache {
     }
 
     if (! -d $cachedir) {
-	if (! -d dirname($cachedir)) {
-	    mkdir(dirname($cachedir))
-		or die "$progname: couldn't mkdir ".dirname($cachedir).": $!\n";
+	my $err;
+	make_path($cachedir, { error => \$err });
+	if (@$err) {
+	    my $msg = join("\n", map { "couldn't mkdir $_->[0]: $_->[1]" } @$err);
+	    die "$progname: $msg\n";
 	}
-	mkdir($cachedir)
-	    or die "$progname: couldn't mkdir $cachedir: $!\n";
     }
 
     download("css/bugs.css");
@@ -3240,7 +3240,7 @@ sub download_attachments {
 		$data =~ s%<HEAD>%<HEAD><BASE href="../">%;
 		$data = mangle_cache_file($data, $thing, 'full', $timestamp);
 	    }
-	    mkpath(dirname $bug2filename{$msg});
+	    make_path(dirname($bug2filename{$msg}));
 	    open OUT_CACHE, ">$bug2filename{$msg}"
 	        or die "$progname: open cache $bug2filename{$msg}\n";
 	    print OUT_CACHE $data;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list