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 ff16025  Check svnmucc put does not update an existing file
ff16025 is described below

commit ff160251053b3e1682a7f77c5e3c96f750f7b9ab
Author: Sebb <[email protected]>
AuthorDate: Wed Jul 22 17:47:56 2020 +0100

    Check svnmucc put does not update an existing file
---
 www/secretary/workbench/tasks.rb | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/www/secretary/workbench/tasks.rb b/www/secretary/workbench/tasks.rb
index 209c45d..c9f3592 100644
--- a/www/secretary/workbench/tasks.rb
+++ b/www/secretary/workbench/tasks.rb
@@ -84,9 +84,9 @@ class Wunderbar::JsonBuilder
   # index_name - name of index file to update (e.g. cclas.txt)
   # docdir - SVN alias for document directory (e.g. cclas)
   # docname - document name (as per email)
-  # docsig - document signature (may be null)
+  # docsig - document signature (as per email - may be null)
   # outfilename - name of output file (without extension)
-  # outfileext - output file extension
+  # outfileext - output file extension (of main file)
   # emessage - the email message
   # svnmessage - the svn commit message
   # block - the block which is passed the contents of the index file to be 
updated
@@ -104,11 +104,18 @@ class Wunderbar::JsonBuilder
         container = ASF::SVN.svnpath!(docdir, outfilename)
         extras << ['mkdir', container]
         dest.each do |name, file|
+          # N.B. file cannot exist here, because the directory was created as 
part of the same commit
           extras << ['put', file.path, File.join(container, name)]
         end
       else
         name, file = dest.flatten
-        extras << ['put', file.path, 
ASF::SVN.svnpath!(docdir,"#{outfilename}#{outfileext}")]
+        outpath = ASF::SVN.svnpath!(docdir,"#{outfilename}#{outfileext}")
+        # TODO does it matter that the revision is not known?
+        if ASF::SVN.exist?(outpath, nil, env)
+          raise IOError.new("#{outpath} already exists!")
+        else
+          extras << ['put', file.path, outpath]
+        end
       end
 
       text = yield text # update the index

Reply via email to