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/30 15:31:49 UTC
[whimsy] branch master updated: Move iclas.txt update to secretary
workbench
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 61e6e79 Move iclas.txt update to secretary workbench
61e6e79 is described below
commit 61e6e7974ee3bcb964cb6477912b4ab29e21ab5f
Author: Sebb <se...@apache.org>
AuthorDate: Wed Dec 30 15:31:38 2020 +0000
Move iclas.txt update to secretary workbench
---
lib/spec/lib/icla_spec.rb | 11 ++++++++---
lib/spec/spec_helper.rb | 13 +++++++++++++
lib/whimsy/asf/documents.rb | 15 ++++++++++++++-
repository.yml | 1 -
4 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/lib/spec/lib/icla_spec.rb b/lib/spec/lib/icla_spec.rb
index 4543e9d..43f1c53 100644
--- a/lib/spec/lib/icla_spec.rb
+++ b/lib/spec/lib/icla_spec.rb
@@ -4,14 +4,19 @@
require 'spec_helper'
require 'whimsy/asf'
-set_svnroot # need access to listing file
-
# Test data:
# ab/ abc.pdf abcd/ abcde/
# N.B. does not make sense for top-level directory to contain more than 1 entry with same stem;
# in such cases the files are moved to a subdirectory
describe ASF::ICLAFiles do
+ original = nil
+ before(:all) do
+ original = set_cache # need access to listing file
+ end
+ after(:all) do
+ set_cache(original)
+ end
describe "ASF::ICLAFiles.listnames" do
it "should return 4 files" do
res = ASF::ICLAFiles.listnames
@@ -76,4 +81,4 @@ describe ASF::ICLAFiles do
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/spec/spec_helper.rb b/lib/spec/spec_helper.rb
index 12535c7..689d4d1 100644
--- a/lib/spec/spec_helper.rb
+++ b/lib/spec/spec_helper.rb
@@ -21,6 +21,19 @@ def set_svnroot # ensure can access svn directory listing files
ASF::Config.setsvnroot File.expand_path("../test/svn/*", __dir__)
end
+def set_cache(restore=nil) # ensure can access test version of iclas.txt
+ config = ASF::Config.instance_variable_get(:@config)
+ original = config[:cache]
+ if restore
+ config[:cache] = restore
+ else
+ source = File.expand_path("../test/svn/", __dir__)
+ FileUtils.touch File.join(source,'iclas.txt') # ensure it is marked as up-to-date
+ config[:cache] = source
+ end
+ return original
+end
+
def set_svn(name)
ASF::SVN[name] = File.expand_path("../test/svn/#{name}", __dir__)
end
diff --git a/lib/whimsy/asf/documents.rb b/lib/whimsy/asf/documents.rb
index 532d08d..71e1a16 100644
--- a/lib/whimsy/asf/documents.rb
+++ b/lib/whimsy/asf/documents.rb
@@ -39,6 +39,7 @@ module ASF
end
# Common class for access to documents/iclas/ directory
+ # Only intended for use by secretary team
class ICLAFiles
@@tag = nil # probably worth caching iclas
@@list = nil # this list includes trailing '/' so can detect directories correctly
@@ -90,7 +91,19 @@ module ASF
# This returns the list of names in the top-level directory
# directory names are terminated by '/'
def self.listnames
- @@tag, list = ASF::SVN.getlisting('iclas', @@tag, false)
+ iclas = 'iclas'
+ cache_dir = ASF::Config.get(:cache)
+ # iclas.txt no longer updated by cronjob
+ file, _ = ASF::SVN.listingNames(iclas, cache_dir)
+ age = (Time.now - begin File.mtime(file) rescue 0 end).to_i
+ if age > 600 # 5 minutes
+ Wunderbar.warn "Updating listing #{file} #{age}"
+ filerev, svnrev = ASF::SVN.updatelisting(iclas, nil, nil, false, cache_dir)
+ if filerev && svnrev # it worked
+ FileUtils.touch file # last time it was checked
+ end
+ end
+ @@tag, list = ASF::SVN.getlisting(iclas, @@tag, false, false, cache_dir)
if list # we have a new list
# update the list cache
@@list = list
diff --git a/repository.yml b/repository.yml
index fcd2c6b..4cd06c6 100644
--- a/repository.yml
+++ b/repository.yml
@@ -136,7 +136,6 @@
iclas:
url: private/documents/iclas
depth: delete
- list: true
incubator-content:
url: asf/incubator/public/trunk/content