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 d7ed1e00 Tidy missing links
d7ed1e00 is described below

commit d7ed1e001a689c409b3bbd369a2c7286c21ef040
Author: Sebb <[email protected]>
AuthorDate: Tue May 10 23:49:15 2022 +0100

    Tidy missing links
---
 tools/merge_subscriptions.rb | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tools/merge_subscriptions.rb b/tools/merge_subscriptions.rb
index a29b52bf..0afd4767 100644
--- a/tools/merge_subscriptions.rb
+++ b/tools/merge_subscriptions.rb
@@ -115,6 +115,19 @@ def merge_files(old_host, new_host, out)
     end
   end
 
+  # Remove any dangling files/links (e.g. after a list is removed)
+  Find.find(File.join(out, 'cache')) do |path|
+    next if File.directory? path
+    unless File.exist?(path) && File.ftype(path) == 'link'
+      $stderr.puts "WARN: Removing real file or missing link #{path}"
+      begin
+        File.unlink(path)
+      rescue StandardError => e
+        $stderr.puts "WARN: Failed to remove path #{e.inspect}"
+      end
+    end
+  end
+
   # Update the timestamp
   FileUtils.copy_file(File.join(new_host, 'list-start'), File.join(out, 
'list-start'), true)
 end

Reply via email to