From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id ONgFF0/0vWFhHwAAgWs5BA (envelope-from ) for ; Sat, 18 Dec 2021 15:46:39 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id YAa0Ek/0vWG7OQAAbx9fmQ (envelope-from ) for ; Sat, 18 Dec 2021 14:46:39 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id F237324505 for ; Sat, 18 Dec 2021 15:46:38 +0100 (CET) Received: from localhost ([::1]:43866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1myays-0000zd-6E for larch@yhetil.org; Sat, 18 Dec 2021 09:46:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1myay4-0000yz-Cy for emacs-orgmode@gnu.org; Sat, 18 Dec 2021 09:45:49 -0500 Received: from [2607:f8b0:4864:20::52c] (port=43610 helo=mail-pg1-x52c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1myay2-0008UY-P5 for emacs-orgmode@gnu.org; Sat, 18 Dec 2021 09:45:48 -0500 Received: by mail-pg1-x52c.google.com with SMTP id q16so4987956pgq.10 for ; Sat, 18 Dec 2021 06:45:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=CnV81aiV/QMa8FQhFLumiAdE+dpoF35zKLo8kfmBf8Q=; b=mdBQdxssj8Up9Hr9WC3qzpMkZbOfaB/QcsqPWQ7lOW8Fc5viz/ASOAWM/r8tL2WAdj I6TscXKBteb3tkiqYcMfh3g4QNfZCIwH7t1pjjmJkbc0TJcJ12VD3a4NYNkpPkJSN/Ov sF8EVUdWg9TypAnRYrBK/39ykq4EasaryMw3KMAGRKy36k7uFgqZ4kuGQW2Zn8JXa+SH pZ8WBU9AvKY2WYheLvFEQTz3goBRmAstHdqxFlzbccFQNld12U3pi5m6bpEWnMeRC/nN zsgXwbMqaaxLEEeGeq8qImMb6J3h6kctl+DILZ5raEJ1Qaz7F2s4gfKvUju/HAm2S+ed kRkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=CnV81aiV/QMa8FQhFLumiAdE+dpoF35zKLo8kfmBf8Q=; b=In6IriYUFOBqdcoIDBdM5JZwKovH4b/u3SvfHDP8/KfSx4H0y7gECiZabjSWYE9sFm oUETJLLKYzgkEGM58tWfVKhhvJvfdEQYnBYKRwDAkBc/ZEkRJYTz5ssspxTzqtv9mVLl NzxjC2XS1lZMycHkhGRRogWFld+rTngFl8Yf3GAd/2j6KRHRXSqCuOVlmDxvzbMNQobd rgE72bpd6S69fGnVIMzDI3NX3TR3p9iuCv57MIrisYJcZs5PDTqmYAsAISYYL19jiHnW ywRhq4tU4X3h7P1fCdAneaHXJUUqFk6zRf66dIL5QC9sUDpjxanLqf5H+rDHqy4kGiec vEAw== X-Gm-Message-State: AOAM531s8c3hd/+0ORNeP8lRANQeFyC5cWW7E5dw3vpSmkYDR6/pWy0Q bpLnjaKhd26bUgvlaZWxmwo= X-Google-Smtp-Source: ABdhPJy4+1sRCxe74OrlJrN4kV/ESyW4eT/xJnD1n0P2vB5j8hZVEbeXQYG8LPRGVXHhBFVVQInaBQ== X-Received: by 2002:a63:d117:: with SMTP id k23mr7281747pgg.287.1639838745394; Sat, 18 Dec 2021 06:45:45 -0800 (PST) Received: from localhost ([50.7.251.66]) by smtp.gmail.com with ESMTPSA id m11sm13422448pfk.27.2021.12.18.06.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Dec 2021 06:45:44 -0800 (PST) From: Ihor Radchenko To: Lele Gaifax Subject: Re: org-persist cache for remote files In-Reply-To: <87ee6aq8sg.fsf@metapensiero.it> References: <87o87kb64s.fsf@yandex.com> <87tuhcfc3n.fsf@localhost> <87czo0nqw4.fsf@yandex.com> <87o87kchi2.fsf@localhost> <8735owawla.fsf@yandex.com> <87lf2oc9sv.fsf@localhost> <87ee8fncmw.fsf@yandex.com> <87fssvdfxj.fsf@localhost> <87wnk3c58c.fsf@metapensiero.it> <87bl1eilt6.fsf@localhost> <87ilvmqujm.fsf@metapensiero.it> <87y24i2dv1.fsf@localhost> <87ee6aq8sg.fsf@metapensiero.it> Date: Sat, 18 Dec 2021 22:47:05 +0800 Message-ID: <87lf0i2cnq.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::52c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=yantar92@gmail.com; helo=mail-pg1-x52c.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1639838799; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=CnV81aiV/QMa8FQhFLumiAdE+dpoF35zKLo8kfmBf8Q=; b=RBHZrLp/g6K5hrKQRkgUdjvDaji5SVpJT5QcKbZ8VUCXyDPFDIiLKufVSvxTJ+1b5XKdh4 0JBXn2ZQyxCiFIiE/GIx4xNnWOBO/dLMLn/bEef2C0RtELC420gcsYyg5ul1uz7t1x5xpf qhySFbY/4FeEXvrvZ7RN3moEWulHbbnfoLT0b9+UJRdlFNjY8+79wKRq8Vk8IXxZQ+xSpp +dx+vtJtcMS+4QNs2Gr8CFJ9/VTlJ+2eMje/7M1WIhSSO3410b2e60iPa5d3DXmwIGnDbC 7/b0kkBm+QCg2CSFxHypeU3Yvi+Z5HVCdgBXQoMVDnKVu2K0mv9fYUwGHcDJig== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1639838799; a=rsa-sha256; cv=none; b=Q2UVSUuF8mfhAMvYD8g9yy9Lm3BfBVav6xo27lry5VRj+QBwoABc56PbG6FG4YklNtMyqU tq/1cu0+1RD1brorN8hStKgNnGznGDX2yf9r0rwmEndCS1EgWdOBOOo0Qku/Y06YyfO1BM tsBOUS0Be4nQ6lNIJngNZlomg3SZ9n44HghT9alU3ZLvgUhdR+wBgIST5ufLFIDNocrD6R atJPb3IBt8oQvDbqaFtyt6Q0UU4wD6WlXjNcPKR1n74UMbi5JL5fMhhC56j0f46zsN8Xpi NBk70dfBJfNfgnKhX23fAuSoSv0JTy9HCX1aZamJnFZxT88smrV9wv9nbg8MMA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=mdBQdxss; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -7.21 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=mdBQdxss; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: F237324505 X-Spam-Score: -7.21 X-Migadu-Scanner: scn0.migadu.com X-TUID: aH0motqIXgDq --=-=-= Content-Type: text/plain Lele Gaifax writes: > In the meanwhile, here below some notes: Thanks! See the updated patch. Best, Ihor --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-org-persist.el-Customise-persistence-of-data-for-rem.patch >From 92878fab54c26800562409f3c686f065b7523a61 Mon Sep 17 00:00:00 2001 Message-Id: <92878fab54c26800562409f3c686f065b7523a61.1639838789.git.yantar92@gmail.com> From: Ihor Radchenko Date: Sat, 18 Dec 2021 22:14:24 +0800 Subject: [PATCH] org-persist.el: Customise persistence of data for remote files * lisp/org-persist.el (org-persist-remote-files): New defcustom defining strategy for persisting data associated with remote files. Separate strategy is necessary to avoid unexpected password promtps while garbage collecting the cache: remote files may require server login. (org-persist-gc): Decide whether to store remote file data according to `org-persist-remote-files'. Reported in https://list.orgmode.org/87bl1eilt6.fsf@localhost/T/#u --- lisp/org-persist.el | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/lisp/org-persist.el b/lisp/org-persist.el index 90f9a3bc9..4c0673c72 100644 --- a/lisp/org-persist.el +++ b/lisp/org-persist.el @@ -57,6 +57,23 @@ (defcustom org-persist-directory (expand-file-name :group 'org-persist :type 'directory) +(defcustom org-persist-remote-files 100 + "Whether to keep persistent data for remote files. + +When this variable is nil, never save persitent data associated with +remote files. When `t', always keep the data. When +`check-existence', contact remote server containing the file and only +keep the data when the file exists on the server. When a number, keep +up to that number persistent values for remote files. + +Note that the last option `check-existence' may cause Emacs to show +password prompts to log in." + :group 'org-persist + :type '(choice (const :tag "Never" nil) + (const :tag "Always" t) + (number :tag "Keep note more than X files") + (const :tag "Check if exist on remote" 'check-existence))) + (defvar org-persist-index-file "index" "File name used to store the data index.") @@ -287,15 +304,26 @@ (defun org-persist-read-all-buffer () (defun org-persist-gc () "Remove stored data for not existing files or unregistered variables." - (let (new-index) + (let (new-index (remote-files-num 0)) (dolist (index org-persist--index) - (let ((file (plist-get index :path)) - (persist-file (when (plist-get index :persist-file) - (org-file-name-concat - org-persist-directory - (plist-get index :persist-file))))) + (let* ((file (plist-get index :path)) + (file-remote (when file (file-remote-p file))) + (persist-file (when (plist-get index :persist-file) + (org-file-name-concat + org-persist-directory + (plist-get index :persist-file))))) (when (and file persist-file) - (if (file-exists-p file) + (when (and file-remote persist-file) + (cl-incf remote-files-num)) + (if (if (not file-remote) + (file-exists-p file) + (pcase org-persist-remote-files + ('t t) + ('check-existence + (file-exists-p file)) + ((pred #'numberp) + (<= org-persist-remote-files remote-files-num)) + (_ nil))) (push index new-index) (when (file-exists-p persist-file) (delete-file persist-file) -- 2.32.0 --=-=-=--