From patchwork Sat Oct 28 17:43:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Kalandyk X-Patchwork-Id: 55466 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9406027BBEA; Sat, 28 Oct 2023 18:49:59 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1D23727BBE2 for ; Sat, 28 Oct 2023 18:49:59 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwnRM-0006bK-1i; Sat, 28 Oct 2023 13:49:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwnRI-0006b0-11 for guix-patches@gnu.org; Sat, 28 Oct 2023 13:49:36 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwnRG-0002sx-SR; Sat, 28 Oct 2023 13:49:35 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qwnRi-0004Gg-1v; Sat, 28 Oct 2023 13:50:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#66799] [PATCH] Fix guix locate clear database "no files to search for" error and unnesecary database rebuilding Resent-From: Maciej Kalandyk Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sat, 28 Oct 2023 17:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66799 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 66799@debbugs.gnu.org Cc: Maciej Kalandyk , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by submit@debbugs.gnu.org id=B.169851536516355 (code B ref -1); Sat, 28 Oct 2023 17:50:01 +0000 Received: (at submit) by debbugs.gnu.org; 28 Oct 2023 17:49:25 +0000 Received: from localhost ([127.0.0.1]:39504 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qwnR6-0004Fj-Lr for submit@debbugs.gnu.org; Sat, 28 Oct 2023 13:49:25 -0400 Received: from lists.gnu.org ([2001:470:142::17]:52596) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qwnR0-0004F2-LS for submit@debbugs.gnu.org; Sat, 28 Oct 2023 13:49:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwnQN-0006JF-Hk for guix-patches@gnu.org; Sat, 28 Oct 2023 13:48:39 -0400 Received: from mail-db3eur04olkn081a.outbound.protection.outlook.com ([2a01:111:f400:fe0c::81a] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwnQL-0002pD-FQ for guix-patches@gnu.org; Sat, 28 Oct 2023 13:48:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LuNMwFR6f27nvTIShOVDME3/narlUdZ4TY0/qKxkXf2ov91NVv+VDKdd50L8dzoIvj9YzmccfRAZ2H9yu/8HAIGYP3k9BsjznKKPzcf5n3sXEdqy4hi+MaBj74vbwj8iJbXcekmDuvWk4TZN/P0+YZkVOF7qKO0MXmkVNsMP4LEMWaQ0hXblCyebkFMY1m+/zGEoeNu293thTUBcbw0GlLUut5YwpBgSo6/FnZ8o2rIF6STFjwbIRyH6ERD2wBIP7yDIiZ0kiSmfBP6FtcOLj9GM9Ngs/bAPd00W2LHEEktahuELrqtVn8jFf9wzxXfyP02BAhmTre1SOFRbogj0vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=foMjcWbgOpDlk9pt2DWb2XJaH5W6Lj4dBh1nLxMM2l4=; b=lnGD38zyiqFabun8XsimfZcG2RIHovcdHOCakXk52TAZIXQjzQ6eSkaUMlwSZv5TLxKyU/D8UfDaVX7qi0TmtZKYC2sS2qWLBzoMM5mUYgOs/wUrw70QKHwFs0qNbgWMs8DAmAWBsEaP7BEkqx4g9XhKOPYXJnQLIM1+6VEN7h4GgGXrLuM4siNLYNAFw8aKnq6wb+QbNDqFU+IRAsTKgSgAJ2Yxqa/H0rpXcbEfoMF7I6fLZQc6KUrHn6KMoKuqgnyb/kPjQc0nbGD1IoNVb+09xTIcXIhUTKH5GdOEXI6QoMIhshvgyPZvmFI17350NWTQpxnyeIzK61LdXUrnyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=foMjcWbgOpDlk9pt2DWb2XJaH5W6Lj4dBh1nLxMM2l4=; b=c4v3uJKkFZKwH02zh0+ZnjVJEp/k/HZEcR92zZB/czn1AsKq1n+rNWUgc2k5xktoVvxZSMBdXybSuiGVsjlhV4v9Gg3kS/VLzQS43fM7DyfgBjjsBVUOrSbNcjjlBeZ5QxOLSieiG28ju+T7m0M8W6Wd8wP9UNX3XmH99OkA6S/KycojUxDQJjNMmmLFvU2P9riDsf9utuGJlCfnyInv67QWZ+6J+opOENBpvrGPXy3nY7fQSNUHObkrQNkE28/pGSFwInBTdoGvH7tPZcvVJsZUOH9wu6Bwv2wxPj5QWmi75JludE4M8+vrhU20c5JZiHrBesL7yq5dE4XGM5xVgA== Received: from AM0PR10MB3586.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:157::23) by AS4PR10MB6205.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:589::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.25; Sat, 28 Oct 2023 17:43:33 +0000 Received: from AM0PR10MB3586.EURPRD10.PROD.OUTLOOK.COM ([fe80::d712:c565:e64a:7439]) by AM0PR10MB3586.EURPRD10.PROD.OUTLOOK.COM ([fe80::d712:c565:e64a:7439%4]) with mapi id 15.20.6933.025; Sat, 28 Oct 2023 17:43:33 +0000 From: Maciej Kalandyk Date: Sat, 28 Oct 2023 19:43:25 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 X-TMN: [dmLazeLChlKLac+Skp8wm8ClAE8NFPCe] X-ClientProxiedBy: FR5P281CA0057.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f0::15) To AM0PR10MB3586.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:157::23) X-Microsoft-Original-Message-ID: <835dd70c2e3e945c8dcca74f5d4d7cd33066b414.1698514844.git.m.kalandyk@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR10MB3586:EE_|AS4PR10MB6205:EE_ X-MS-Office365-Filtering-Correlation-Id: e1f7a69c-c80d-4f4d-210e-08dbd7dd6653 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mRg+iwky8wJyJxHXCT4PrzVdTvDxjzRzKc92SfKT86ojSmSbmD5GXlilOc6AkUN6UFZ2+j/265sAZyUbG920pS8XbqtS/vax7maBX/UVNxTaM0P7hh8jMzxRVVLybm8QoXEIBaN90zSYV79tZw9HCiPH3J2kRICOekryHqW84lOniPF5pfcw/ApFGR2D2qpuxoqp59XiGEGO7ys0YZts6lUNuJEwDEsi8KeEXtTMFGUMqQF03kYBzIdlcwtesBYxcaqLfVbFlN3LAP8CWJ+uOlFTDcOWghaUY8DLKCLj5JFO4hJhk5dnXkkAO5qwaPNWWHoW4sahtToiujQqsj+VuW13FxHUAzB8d3wpiPZWBd+i2P1nj0yg/vC5mcvhTUgc4EDQ0rS5/GkwhGZ+NUkLINgeIF46C35aGV7qG9r6krKek/IsC0FjDO+t/IpzP0D4AaX+aZKHGxT9NnDhVLRpB4nnxLSiAaX+1ltFl2bv+cyrQ5p6ubq6Wj6YmXl4VTmNk4iuOkSj/isEL4Miq9NG+ny4sipFrof6yIyFEUtzU7bWAQJ1QEmnQtEAvi8UJD+Fd6IDGei2hIhf8qsgJX0zHi0V5EIDZ4m3i8W6abGMzj2oQ2OIHt29LEFAzQfJHgxe X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xWZxTKdn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Pu871P9ChiGHAJgfFeG+qlLn5k3rArunVccj7WroinNsSBwE8DkJwBI+tOmBASoHAMsa5Q0vsCOI5TneTFJhi5aVnnfdqujFhMDwNBcYCpW5dd1896YA1cPuGf2DDPeA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1f7a69c-c80d-4f4d-210e-08dbd7dd6653 X-MS-Exchange-CrossTenant-AuthSource: AM0PR10MB3586.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2023 17:43:33.2586 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR10MB6205 Received-SPF: pass client-ip=2a01:111:f400:fe0c::81a; envelope-from=m.kalandyk@outlook.com; helo=EUR04-DB3-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches This patch fixes error with guix locate --clear that causes it to display error when no files are supplied Change-Id: I0e9ca223d6406c78b0dd8ff93976c3077d89e103 Signed-off-by: Maciej Kalandyk --- guix/scripts/locate.scm | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) base-commit: 6d7e181ba18d11c92409a93936025fb46b9c8171 diff --git a/guix/scripts/locate.scm b/guix/scripts/locate.scm index ae64f46896..93faa1aea2 100644 --- a/guix/scripts/locate.scm +++ b/guix/scripts/locate.scm @@ -634,6 +634,9 @@ (define-command (guix-locate . args) (_ (leave (G_ "~a: unknown indexing method~%") method)))))) + (if (and (null? files) (not (or update? clear?))) + (leave (G_ "no files to search for~%"))) + ;; Populate the database if needed. (let* ((stat (stat database #f)) (age (and stat (file-age stat))) @@ -649,20 +652,18 @@ (define-command (guix-locate . args) (if (assoc-ref opts 'stats?) (print-statistics database) - (match (call-with-database database - (lambda (db) - (append-map (lambda (file) - (matching-packages db file - #:glob? glob?)) - files))) - (() - (if (null? files) - (unless update? - (leave (G_ "no files to search for~%"))) + (unless (null? files) + (match (call-with-database database + (lambda (db) + (append-map (lambda (file) + (matching-packages db file + #:glob? glob?)) + files))) + (() (leave (N_ "file~{ '~a'~} not found in database '~a'~%" "files~{ '~a'~} not found in database '~a'~%" (length files)) - files database))) - (matches - (leave-on-EPIPE - (print-matching-results matches)))))))) + files database)) + (matches + (leave-on-EPIPE + (print-matching-results matches)))))))))