From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:32973) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1Gnv-0004sl-3P for guix-patches@gnu.org; Fri, 23 Aug 2019 17:09:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1Gnu-0005Do-2V for guix-patches@gnu.org; Fri, 23 Aug 2019 17:09:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:60724) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i1Gnt-0005De-VS for guix-patches@gnu.org; Fri, 23 Aug 2019 17:09:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i1Gnt-0003Kp-O4 for guix-patches@gnu.org; Fri, 23 Aug 2019 17:09:01 -0400 Subject: [bug#36976] [PATCH 1/1] download: Map file-name characters not allowed in store. Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20190808144448.25147-1-h.goebel@crazy-compilers.com> Date: Fri, 23 Aug 2019 23:08:29 +0200 In-Reply-To: <20190808144448.25147-1-h.goebel@crazy-compilers.com> (Hartmut Goebel's message of "Thu, 8 Aug 2019 16:44:48 +0200") Message-ID: <874l271tf6.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Hartmut Goebel Cc: 36976@debbugs.gnu.org Hello, Hartmut Goebel skribis: > In the file-name to be used for storing into the store, replace any > character not allowed in the store-file-name by an underscore. > This is only done when NAME is not given and thus defaults to > toe URL's basename. If NAME is given, this is used unchanged, > allowing for more control by other functions. > > Fixes > > * guix/download.scm (safe-name): New function. > (download-to-store): NAME defaults to the "safe" basename of URL. What about moving this automatic renaming feature to (guix scripts download)? I=E2=80=99d rather not do it in the core APIs. > +(define (safe-name name) > + "Replace any character not allowed in a stroe name by an underscore." ^^ Typo. I=E2=80=99d call it =E2=80=98ensure-valid-store-file-name=E2=80=99 or simil= ar, WDYT? > + (define valid-characters > + ;; according to nix/libstore/store-api.cc > + (string->list (string-append "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > + "abcdefghijklmnopqrstuvwxyz" > + "0123456789" "+-._?=3D"))) > + (string-map (lambda (c) > + (if (member c valid-characters) c #\_)) > + name)) Instead of a list, please use a SRFI-14 =E2=80=9Ccharacter set=E2=80=9D, li= ke this: (define valid (string->char-set =E2=80=A6)) (string-map (lambda (c) (if (char-set-contains? valid c) =E2=80=A6)) name) Thanks, Ludo=E2=80=99.