You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2020/12/29 14:41:35 UTC

[whimsy] branch master updated: Allow override of cached listing directory

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 8eeb1f8  Allow override of cached listing directory
8eeb1f8 is described below

commit 8eeb1f80a7cc42eb71dc07904a8b112bf96fe3b9
Author: Sebb <se...@apache.org>
AuthorDate: Tue Dec 29 14:41:26 2020 +0000

    Allow override of cached listing directory
---
 lib/whimsy/asf/svn.rb | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index 82f521c..d86e725 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -911,12 +911,12 @@ module ASF
     # N.B. The listing includes the trailing '/' so directory names can be distinguished
     # @return filerev, svnrev
     # on error return nil, message
-    def self.updatelisting(name, user=nil, password=nil, storedates=false)
+    def self.updatelisting(name, user=nil, password=nil, storedates=false, dir = nil)
       url = self.svnurl(name)
       unless url
         return nil, "Cannot find URL"
       end
-      listfile, listfiletmp = self.listingNames(name)
+      listfile, listfiletmp = self.listingNames(name, dir)
       filerev = "0"
       svnrev = "?"
       filedates = false
@@ -978,8 +978,8 @@ module ASF
     # or tag, nil if unchanged
     # or Exception if error
     # The tag should be regarded as opaque
-    def self.getlisting(name, tag=nil, trimSlash = true, getEpoch = false)
-      listfile, _ = self.listingNames(name)
+    def self.getlisting(name, tag=nil, trimSlash = true, getEpoch = false, dir = nil)
+      listfile, _ = self.listingNames(name, dir)
       curtag = "%s:%s:%d" % [trimSlash, getEpoch, File.mtime(listfile)]
       if curtag == tag
         return curtag, nil
@@ -1034,8 +1034,12 @@ module ASF
     # get listing names for updating and returning SVN directory listings
     # Returns:
     # [listing-name, temporary name]
-    def self.listingNames(name)
-      dir = self.svn_parent
+    def self.listingNames(name, dir = nil)
+      if dir
+        throw IOError.new("Invalid directory #{dir}") unless Dir.exist? dir
+      else
+        dir = self.svn_parent
+      end
       return File.join(dir, "%s.txt" % name),
              File.join(dir, "%s.tmp" % name)
     end